MySql数据无法被远程连接
MySql数据无法被远程连接
MySql 默认无法被远程连接,只能通过 localhost 或者 127.0.0.1 来本地访问。可以在 navicat 中修改(通过界面操作或者SQL执行)。
use mysql;
##然后查看下当前连接允许情况
select host, user, authentication_string, plugin from user;
##依次执行
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
##再次查看连接情况
select host, user, authentication_string, plugin from user;