Mysql开启远程连接

旧版

vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address            = 0.0.0.0
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
flush privileges; 
/etc/init.d/mysql restart

修改密码:mysql> set password for root@localhost = password('123');

新版

默认装完不需要密码,如需要,查看cat /etc/mysql/debian.cnf默认密码

use mysql;
update user set authentication_string='' where user='root';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH privileges;

重启服务:systemctl restart mysql.service

posted @ 2019-08-16 13:51  秒年度  阅读(192)  评论(0编辑  收藏  举报