MySQL8在实现远程连接(如远程phpmyadmin访问数据库服务器)时,与早期版本有区别,不能用原来的命令(必须同时创建用户和赋权)。
mysql>create user admin@'%' identified by 'admin.';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
mysql>grant all privileges on *.* to 'admin'@'%' with grant option;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'admin'@'192.168.1.3' WITH GRANT OPTION;
mysql>flush privileges;
mysql>ALTER USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY 'admin.';
若服务器经路由器转发,需将内网端口映射到外网端口。否则会报错:The error (2003) Cant connect to MySQL server on server(10061)