【mysql】linux, mac mysql数据库root 密码忘记修改

时间:2023-03-09 16:17:09
【mysql】linux, mac mysql数据库root 密码忘记修改

首先关闭正在运行的mysqld进程

  1. 执行mysqld_safe --skips-grant-tables &
  2. 双击enter 键进入命令行模式
  3. 执行 mysql
  4. linux 系统执行:update mysql.user set password = password('root') where user = 'root' and host = 'localhost';
  5. mac 系统执行:update mysql.user set authentication_string=password('root') where user = 'root' and host = 'localhost';
  6. 刷新权限:flush privileges;
  7. 退出:quit
  8. 杀死mysqld进程,然后重新连接 :mysql -uroot -proot
  9. 完成