mysql change password and authorize remote login

1. Law One

mysql -u root

  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

 2. Law two

Edit the user table directly with UPDATE

  mysql -u root

  mysql> use mysql;

  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

  mysql> FLUSH PRIVILEGES;

 3. Law three

When you lose the root password, you can do this

  mysqld_safe --skip-grant-tables&

  mysql -u root mysql

  mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';

  mysql> FLUSH PRIVILEGES;

 

 

 

4. Authorized users to log in to the database

Authorized user, you want root to connect to mysql server from any host with password
\GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin123' WITH GRANT OPTION;flush privileges;

If you want to allow user root to connect to mysql server from host with ip 192.168.12.16
\GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.16'   IDENTIFIED BY '123456' WITH GRANT OPTION;

 Reference linkhttp://blog.csdn.net/a1079540945/article/details/25770527

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326641058&siteId=291194637