Contact

Contact us

Login

site login

Locking Down MySQL

This document describes basically how to lock down a MySQL server. It should be your first step in setting up a database server!

Change database administrators password:

mysql> SET PASSWORD FOR root@localhost=PASSWORD('new_password')

Remove sample database:

mysql> DROP DATABASE test;

Drop all users and databases we don't need:

mysql> USE mysql;
mysql> DELETE FROM db;
mysql> DELETE FROM user WHERE NOT (host="localhost" AND user="root");
mysql> FLUSH PRIVILEGES;

Change admin username:

mysql> UPDATE user SET user="mydbadmin" WHERE user="root";

Finishing Up:
Remove the mysql command history as we gave the admin password above, this is saved in the command history in plain text.

# rm -f ~/.mysql_history