1.安装mysql过程
见我之前的文章《centos7安装mysql》
2.问题:(1)安装完后登陆不了mysql,总是提示access访问受限
解决方法:先改变my.cnf的mysqld里加入skip-grant-tables
然后mysql -uroot -p直接登录后,
use mysql后
update user set authentication_string=password('新密码') where user='root';
flush privileges;
然后退出后,再把my.cnf里的skip-grant-tables注释掉,重启mysql
(2)修改上述问题后,登录mysql后还是不能正常运行
mysql -uroot -p直接登录后,执行任何命令都报错:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement befo re executing this statement.
只要输入 set password=password('新密码');即可
(3)上述(2)中,如果是mysql5.6.6以后的版本(包含此版本),设置了密码验证插件
想要去掉,就在my.cnf里mysqld下配置
validate_password=OFF
如果想用此,那么就熟悉下密码验证插件的规则吧
然后再登录即可正常操作
(4)授权用户问题
mysql> GRANT USAGE ON *.* TO 'root'@'localhost';
ERROR 1133 (42000): Can't find any matching row in the user table
解决方法:mysql> GRANT USAGE ON *.* TO 'root'@'localhost' identified by password(你的密码);
(5)远程登录
记得关闭防火墙
systemctl status firewalld.service
systemctl stop firewalld.service