Mysql遇到的问题

发布时间 2024-01-05 23:15:50作者: 转角90

Mysql遇到的问题

  1. 使用mysqladmin 修改密码出现的问题
You cannot use 'password' command as mysqld runs
 with grant tables disabled (was started with --skip-grant-tables).
Use: "mysqladmin flush-privileges password '*'" instead

解决问题:skip-grant-tables,跳过密码登录
进入到mysql中
> use mysql
> UPDATE user SET authentication_string=PASSWORD(‘123‘) WHERE user=‘root‘;
> FLUSH PRIVILEGES;
  1. mysql8.0 修改密码
进入到/etc/my.cnf中,加入skip-grant-tables

2. 关闭服务器
service mysqld stop

3. 重启服务器
service mysqld start

4. 进入mysql 
> mysql

5. 选择mysql库
> use mysql

6. 重置密码为空, 其他版本5.7 authentication_stirng =passwrod(新密码)
> update user set authentication_stirng = '' where user='root'

> flush privileges;

> alter user 'root'@'localhost' by '新密码'

7. 退出并修改/etc/my.cnf,去掉skip-grant-tables


# 报错原因:没有更新权限 flush privileges
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement