Securing MySQL Server - setup root password

 

Securing MySQL Server - setup root password

As you see MySQL server connects without any password restriction. This is not a good idea for production environment so let us setup root password with mysqladmin command. By default MySQL server installs without any password and it use root account as admin user for managing MySQL server. Please do not get confused with FreeBSD root user account. Both are different account and password for both accounts should be different for security reasons.

$ mysqladmin -u root password MYPASSWORD

Now try to connect server:

$ mysql

Output:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

To connect to MySQL server use following syntax (when prompted for password type newly set password):

$ mysql -u root -p

Output

Enter password:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 4 to server version: 5.0.9-beta

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql>

Now your server is secured and no one can connect to MySQL server anonymously.
See also:

  • MySQL change root password - it covers few other methods for setting up MySQL root/admin password.

Securing MySQL Server - setup root password

As you see MySQL server connects without any password restriction. This is not a good idea for production environment so let us setup root password with mysqladmin command. By default MySQL server installs without any password and it use root account as admin user for managing MySQL server. Please do not get confused with FreeBSD root user account. Both are different account and password for both accounts should be different for security reasons.

$ mysqladmin -u root password MYPASSWORD

Now try to connect server:

$ mysql

Output:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
To connect to MySQL server use following syntax (when prompted for password type newly set password):

$ mysql -u root -p

Output
Enter password:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 4 to server version: 5.0.9-beta

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql>
Now your server is secured and no one can connect to MySQL server anonymously.
See also:
  • MySQL change root password - it covers few other methods for setting up MySQL root/admin password.

你可能感兴趣的:(Securing MySQL Server - setup root password)