The security of MySQL
First ENTER after
1. Set up a password for MySQL first
2. Delete the user account in the useless MySQL library
3. Delete the test database that exists by default
It can also be more secure.
1. Delete all users in MySQL, including root super user.
Mysql>delete from Mysql.user;
Query ok,2 Rows Affected (0.00 sec)
Tip: Root can be retained and then modified for other users to
2. Add system and upgrade to Super Administrator, that is, the user with root equivalent, but the name is different.
Mysql>grant all privileges on * * [email protected] ' localhost ' identified by ' password ' with GRANT option;
Query ok,0 Rows Affected (0.00 sec)
It is strongly recommended to first create a user and then delete root
Set Password
mysqladmin-u root password ' password '
(This is set without the initial password)
Mysqladmin-u root-p ' password ' password ' oldboy '-s/data/3306/mysql.sock (multi-instance mode)
Change Password
1. Command-line modification
Mysqladmin-u root-p ' 456 ' password ' 123 ' (password changed from 456 to 123) (most commonly used method)
2.sql Statement Modification method
Desc Mysql.user; (View user table table structure)
Select User,host,password from Mysql.user;
Update Mysql.user set password= ' 456 ' where user= ' root ' and host = ' localhost ' (this method is not feasible because it is plaintext and will not succeed)
The right one should be
Update Mysql.user set Password=password (456) where user = ' root ' host = ' localhost ';
Flush privileges;
Changing the current user password in an SQL statement can also be used
Set Password=password (' 123456 ')
Recommendation: Refresh the password after changing it
Flush privileges;
Setting and modifying the MySQL root user password