Secure MySQL

Filed Under Configuration 

The default configuration has “root” with no password. The following shows you how to lock down MySQL by assigning a password to root and creating a super user with all privileges for administration use.

#sudo mysql -u root -p

mysql> use mysql;
mysql> select user, password, host from mysql.user;

Secure root account.

mysql> set password for ‘root’@'localhost’ = password(’password’);
mysql> set password for ‘root’@'hostname’ = password(’password’);
mysql> set password for ‘root’@'127.0.1.1′ = password(’password’);
mysql> flush privileges;

Create superuser ‘admin’ with all privileges accessible from any host.

mysql> grant all privileges on *.* to ‘admin’@'%’ identified by ‘password’ with grant option;
mysql> flush privileges;

Comments

Leave a Reply