mysql allow external network access and modify account password mysql

mysql the root account, I usually use when connecting to localhost or 127.0.0.1, mysql on the company's test server is localhost so I want to access can not access, test pause.

Solutions are as follows:

1, modify the table, log mysql database , switch to the mysql database using sql statement to view "select host, user from user; "

mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user ='root';
mysql>select host, user from user;
mysql>flush privileges;



Note: The last sentence is very important, if the purpose is to validate the modification did not write, you still can not connect remotely.

2, an authorized user, you want to use the root password to connect to the mysql server from any host

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'  IDENTIFIED BY 'admin123'  WITH GRANT OPTION;
flush privileges;

  

If you want to allow the user root from host 192.168.1.104 ip to connect to mysql server

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.104'   IDENTIFIED BY 'admin123'  WITH GRANT OPTION; 
flush privileges;

  

Modify password MySql

Mysql.user deleted from the table in the MySQL 5.7 password fields, the new field name is "authenticalion_string".

Select the database:

use mysql;

Update root password:

update user set authentication_string=password('新密码') where user='root' and Host='localhost';

Refresh permissions:

flush privileges;

 

Guess you like

Origin www.cnblogs.com/sttchengfei/p/11391961.html