How To Secure MySQL Database Server From Anonymous Logins

By | October 28, 2009


Secure MySQL Database Server From Anonymous Logins

MySQL is one of the most popular database server in the world. It’s high performance and cost free attract much more people. MySQL database servers are a common location for attackers. So it is important to check the security setting of each MySQL servers.

Blocking anonymous access and securing MySQL databases with authorized users are more important. This help us to increase the security level of MySQL server and reduce the data loss.

In normal condition fresh installation of MySQL allows anonymous access to the MySQL database server. To increase the security of MySQL server we need to set MySQL root password,block anonymous and network access.


Steps for preventing attacks on MySQL Server.

Set up MySQL root access password.

Open terminal and enter the following commands,

mysqladmin -u root password secretpassword

or

Login into MySQL

# mysql
mysql> use mysql;
mysql> UPDATE user SET password = password('secretpassword') WHERE user = 'root';


Disabling Anonymous Users

# mysql -u root -p mysql

Enter Password: secretpassword

mysql> DELETE FROM user WHERE user = '';
mysql> FLUSH PRIVILEGES;


Disabling Networking in MySQL

Add the following lines into “/etc/my.cnf” file

[mysqld]

# Prevent network access to MySQL.

skip-networking

Cheers!

Melbin Mathew

www.talk2melbin.com

Melbin Mathew

I am Melbin Mathew, Systems Engineer from Kerala, India. I live with my parents, daughter and my wonderful wife. I graduated in 2004 with a bachelor’s degree in Electronics and Hardware from Mahatma Gandhi University, Kottayam and completed certification in MCITP, RHCE, CCNA, VCP ...Read More
Category: Linux

About Melbin Mathew

I am Melbin Mathew, Systems Engineer from Kerala, India. I live with my parents, daughter and my wonderful wife. I graduated in 2004 with a bachelor’s degree in Electronics and Hardware from Mahatma Gandhi University, Kottayam and completed certification in MCITP, RHCE, CCNA, VCP ...Read More