Secure New MySQL Installation
After installing MySQL, it's important that you secure the installation by
a) removing anonymous accounts and
b) setting a password on the admin account.
This can be done with mysqladmin or with direct SQL queries. I prefer the SQL queries so that's what I'll show here.
- Start mysql command line utility and select the mysql database.
- Remove anonymous accounts.
- Set a password on the mysql root account.
- Flush privileges.
[root@localhost]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17073
Server version: 5.5.27 Distributed by The IUS Community Project
mysql> delete from user where user = "";
Query OK, 2 rows affected (0.00 sec)
mysql> update user set password = PASSWORD('aStrongPassword');
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4
Changed: 4
Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye