系统:centos7
mysql版本:5.7
修改 vi /etc/my.cnf
添加
[mysqld]
skip-grant-tables
重启mysql
service mysqld restart
进入mysql
mysql -uroot
进入后修改密码为abc.123
update mysql.user set authentication_string=password('abc.123') where user='root';
flush privileges;
quit退出后,重启mysql
systemctl restart mysqld
测试,使用密码 abc.123
mysq -uroot -p
授权其他IP访问,%任何主机,如果是某网段为 192.168%
grant all privileges on *.* to 'root'@'%' identified by 'abc.123' with grant option;
flush privileges;
另外:对应之前只限定某个test用户,只能从某个具体IP访问,比如之前已经授权了192.168.1.1访问,现在要授权test,192.168.1.2访问
还是用如下授权就报错
grant all privileges on *.* to 'test'@'192.168.1.2';
需要先新增一条记录,再