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
$ 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
OutputEnter password:Now your server is secured and no one can connect to MySQL server anonymously.
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>
See also:
- MySQL change root password - it covers few other methods for setting up MySQL root/admin password.
本文介绍如何使用mysqladmin命令为MySQL服务器设置根用户密码,确保生产环境中数据库的安全性,并提供连接验证的方法。

754

被折叠的 条评论
为什么被折叠?



