disable client host connection after many failed attempts in mysql - mysql

in mysql 5.5 error logs I see many Access denied for user .... from the same ips. I thought mysql would put a host in blocked_host or something similar after 10 failed connection attempts, but it doesn't seem to be. Is there a way to enforce this?

AFAIK, No that will not be done automatically. You can configure for tracking login failure
event using auditing logon failure event and use triggers for performing some
action on failure event.
See this articles
auditing-login-attempts-in-mysql
Audit logins on MySQL database
But best would be to perform this blocking/locking of account at application level and not at DB level.
Blocking access to the login page after three unsuccessful login attempts

Related

AWS RDS automatically stopping soon after it is started

I have created an RDS on AWS which initially shows the status of 'available' but when I use my sql client to connect to it I receive the error:
Status : Failure -Test failed: IO Error: Connection reset by peer, Authentication lapse 0 ms
Then when I check the status of the RDS online (AWS dashboard) it says 'stopping'.
When I try to start the RDS again it's status will go from 'starting' to 'stopping' after a couple of minutes and then eventually 'stopped'. I can't find anything online referring to an RDS automatically stopping and I am somewhat a novice to AWS.
Based on the comments.
The solution was found by checking CloudTrial Event history. Based on the search it was identified that StopDBInstance was issued by HIPComplianceWorker user.
This probably means that there is an automation that checks the db instances launched and verifies if they comply with your companies policies. Your instance could be violating such policies, and it was automatically stopped.
You would have to contact your admins to check with them what kind of RDS you can use.

Using localdb with a computer on a domain but without a connection gives: SQL Server connection error

We expect our software to be able to run on computers connected to a domain. We also expect to be able to connect to a localdb we created under the user account. But when we take the laptop to another network where it can't contact the domain controller we get the following error:
Could not obtain information about Windows NT group/user
'OURDOMAIN\AUser', error code 0x54b.
Is there something I can do to make it work? It seems reasonable to me to expect a domain user's privileges to be remembered when a server is out of sight. Interestingly, if it's not connected to any network it does work ok - it only fails when it is connected to another network.
(I don't want something drastic like "log off and use a local account not on the domain", but something normal and workable for a domain user and installation!)
This error was coming from the simple fact the database owner was the domain user. It would seem that the SQL underlying code likes to check authenticity now and again and so that caused occasional failures in random bits of SQL.
Fixed it by changing the owner to an SQL user:
CREATE LOGIN [ourLocalDbOwner] WITH PASSWORD='';
ALTER AUTHORIZATION ON DATABASE::ourDatabase TO [ourLocalDbOwner];

mysql on ec2 amazon instance attempting to login with incorrect user

I've set up a very basic LAMP setup on an ec2 server, all good it seems to work.
However i've seen for some queries a failure to connect to the mysql server with the following error:
[07-Jul-2013 20:15:41 Australia/Sydney] PHP Warning: mysql_real_escape_string(): Access denied for user 'ec2-user'#'localhost' (using password: NO) in /var/www/html/mycobber/class/sql/SqlQuery.class.php on line 40
[07-Jul-2013 20:15:41 Australia/Sydney] PHP Warning: mysql_real_escape_string(): A link to the server could not be established in /var/www/html/xxx/xxxx/sql/SqlQuery.class.php on line 40
the thing i dont' understand is the fact that in no location in my mysql connection configuration does it specify the user ec2-user. this is the default user when I log onto the unix server. I've set up a separate account to actually run all my processes, i dont' even use the es2-user.
I've looked online and can't see anything to explain this. does anyone have an idea what's going on here. it's not all the time
Your can't call mysql_real_escape_string without having opened a connection with mysql_connect first.
Quoting from the documentation:
A MySQL connection is required before using mysql_real_escape_string() otherwise an error of level E_WARNING is generated, and FALSE is returned.
The error message refers to your default username # localhost because you haven't opened a connection with specific credentials yet - it doesn't know what account details to use.

Unable to create indexes in Sphinx after an emergency server restart [Can't create TCP/IP socket]

I'm trying to execute the command in the Windows console:
C:\SphinxSearch\bin\indexer --all --config C:\SphinxSearch\sphinx.conf
But I get an error:
ERROR: index 'indexname': sql_connect: Can't create TCP/IP socket
(10093) (DSN=mysql://root:*#localhost:3306/test).
A data source is mysql. Before the server restart everyone works fine.
How can I fix it?
I'm having the same error 10093. It's a windows error code by the way. In my case it occurs when trying to run the indexer through the system account via a scheduled task. If I'm running it directly as administrator, there's not a problem.
According to the site above:
Either your application hasn't called WSAStartup(), or WSAStartup() failed, or--possibly--you are accessing a socket which the current active task does not own (i.e. you're trying to share a socket between tasks).
In my case I'm thinking it might be the last one, some security problem due to user SYSTEM being used in my scheduled task. I was able to solve it by using my admin user instead: in the scheduled task, I set to use my local admin account with the option to "Run when user is logged on or not" and "Do not store password". I've also checked "Run with highest privileges". This seems to have done the trick as now my indexes are rotating on schedule.

Find the number of active connections per database in MySQL

I have a drupal application that uses the database named db1. Each time a drupal request is sent, a new connection to database will be established.So after a certain number of conneections has reached the site turns offline showing the following error:
User db1 already has more than 'max_user_connections' active connections.
So my aim is to close the database connection and thereafter avoiding the offline error. For this I need to find the number of active connections made to my database.I have tried with the SHOW PROCESSLIST command. But it is not showing the number of connections.
Is there any method to find the number of database connections made to a mysql database?
Thanks,
SHOW STATUS LIKE 'threads_connected';
Although if your Drupal (or the webserver to be precise) is not closing connections automatically after each request, there's probably something that is not configured correctly.