Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
My server's been hacked EMERGENCY

My MySQL database is getting hacked daily.

Hackers are uploading shell and files in others cpanel to the server, and getting the users and passwords from the database, login from web based mysql managers, etc.

Is there any way to block localhost login to my database? Or hide the tables? Or any other idea?

share|improve this question

marked as duplicate by EEAA, Tim Brigham, Tom O'Connor, Mark Henderson Apr 23 '12 at 6:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
can you provide some more information about your setup, are you saying that you are on a shared box and that other local users are using their user@localhost to access your mysql database? –  Tom H Apr 22 '12 at 12:38
    
I would post the output of the following commands select user, host, db from mysql.db\G and select Host,Db from mysql.host\G and select user, host from mysql.user\G and look and see which users have '%', localhost or 127.0.0.1 access. –  Tom H Apr 22 '12 at 12:43
    
you can also use DROP USER 'jeffrey'@'localhost'; and DROP USER 'jeffrey'; to remove those instances that have no password set –  Tom H Apr 22 '12 at 12:46
    
I bet you're running something written in PHP. Aren't you? Aren't you. –  Tom O'Connor Apr 22 '12 at 17:39
1  
@TomO'Connor - My guess is phpmyadmin. That's a hateful piece of software, especially un-patched. –  Mark Henderson Apr 23 '12 at 6:26

2 Answers 2

How about securing your server?

  • Find the reason why they are able to upload shells, then close the hole.
  • How is it possible they are able to access your database? Different users different passwords. MySQL has a proper role and authentication system, use it.
  • Update everything.
  • Use a firewall/ACL

If you don't understand what I'm talking about, you might consider getting in a consultant to fix these issues for you.

share|improve this answer

If you absolutely have to expose mysql to the public network then you should set a very complex password, and consider using iptables to limit those addresses that can access the service remotely.

However as general rule, for whatever reason you want to export MySQL to the network, it is not a good idea. If you are on linux, (or with putty on windows) you can use SSH and a local port forward to make the remote database appear to local development applications with a command like ssh user@remoteserver.com -L 3306:localhost:3306

you can use the show grants for 'user' command to see which users have access to your database, and which hosts they can connect from. You can also use the following commands (as a starting point) for enumerating the users who can access the server, database locally or remotely;

 select user, host, db from mysql.db\G 

 select Host,Db from mysql.host\G

 select user, host from mysql.user\G 

you can also use DROP USER 'jeffrey'@'localhost'; and DROP USER 'jeffrey'; to delete the accounts that have been created.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.