MySQL 5.7 安装完成后,允许root远程登录
-
MySQL 所在服务器执行命令,直接登陆数据库
mysql -u root -p
切换到 mysql 这个库
mysql> use mysql
查询数据库用户信息
SELECT User, authentication_string , Host FROM user;
MySQL [mysql]> SELECT User, authentication_string , Host FROM user; +---------------+-------------------------------------------+-----------+ | User | authentication_string | Host | +---------------+-------------------------------------------+-----------+ | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost | | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost | | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost | | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 127.0.0.1 | +---------------+-------------------------------------------+-----------+ 4 rows in set (0.00 sec)
新增root 可以所有来源IP段访问
账号root 密码 root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
刷新权限
FLUSH PRIVILEGES;
修改root密码
update mysql.user set authentication_string=password('密码') where user='root';