赞
踩
1.查看debian-sys-maint用户的密码:
在目录 /etc/mysql/ 下的这个debian.cnf文件,使用sudo cat debian.cnf进行密码的查看
2.debian-sys-maint用户登录mysql,设置root用户密码和访问权限
mysql -u debian-sys-maint -p
XXXXXXXXXXXXXXX
use mysql;
update mysql.user set authentication_string=password('111111')where user='root'and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
quit;
3.#/etc/mysql/mysql.conf.d/mysqld.cnf 中设定只接受localhost链接
vi /etc/mysql/mysql.conf.d/mysqld.cnf
#从网络节点链接mysql,需要用#注释掉bind-address !!!
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
4.重新使用debian-sys-maint用户访问mysql,为root授权远程访问
mysql -u debian-sys-maint -p
XXXXXXXXXXXXXXX
use mysql;
grant all privileges on *.* to 'root'@'%' identified by '111111' with grant option;
quit;
#重启mysql服务
#sudo service mysql restart
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。