mysql相关问题解决
问题分析:一般是密码错误,修改密码步骤如下。
skip-grant-tables
2.重启mysql服务
#service mysqld restart
3.设置root密码
mysql8.0--->alter user ‘root’@’localhost’ IDENTIFIED BY ‘你的密码’; mysql5.7--->update user set password=password('123456') where user = 'root';
4.可能报下面错误
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
5.刷新权限后执行修改密码操作
mysql>flush privileges;
6.删除my.cnf中添加的内容并重启mysql
mysql>use mysql; mysql>select user,host,plugin from user;
mysql>alter user 'root'@'%' identified with mysql_native_password by '你的密码'; mysql>flush privileges;
mysql> use mysql;
mysql>select user,host from user;
+------------------+-----------+ | user | host | +------------------+-----------+ | mysqld | % | | root | % | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | +------------------+-----------+
2.注意到root用户对用的host是%,要修改密码,要使用下面的指令
mysql>alter user 'root' @'%' identified by '你的密码'; mysql>flush privileges;
3.也可以修改root对应的host为localhost在进行alter操作
mysql>update user set host='localhost' where user='root';
mysql> use mysql; mysql> update user set host='%' where user='root'; mysql> flush privileges;
2.开启权限
mysql> grant all privileges on *.* to 'root'@'%' identified by '数据库密码' with grant option; mysql> flush privileges;
3.开启3306端口(centos系统)
3.1 查看是否开启3306端口
#netstat -tunlp
3.2 启动防火墙
#systemctl start firewalld
3.3 添加3306端口
#firewall-cmd --permanent --add-port=3306/tcp #firewall-cmd --reload