重置忘记的mysql root密码

时间:2022-08-04 00:33:24

步骤

  1. 停止mysql服务

  2. 进入mysql安全模式
    mysqld_safe –skip-grant-tables

  3. mysql -u root -p

  4. use mysql;

  5. describe user;

  6. update user set authentication_string= password(‘123456’) where user=’root’;

  7. flush privileges;

  8. 重启mysql

题外话:mac为当前用户配置mysql环境变量
vim ~/.bash_profile
export PATH=$PATH:/usr/local/mysql-5.7.17-macos10.12-x86_64/bin
source .bash_profile