mac 环境下初始化mysql的root密码

  1. 关掉mysql服务,打开系统设置最后的mysql,然后将mysql先关掉

  2. 生成一个文件命名mysql-init,文件中放入:一句话,这句话不同版本不一样,如下:

    • MySQL 5.7.6 and later:

      alter user ‘root’@‘localhost’ identified by ‘新密码’;
      
    • MySQL 5.7.5 and earlier:

        set password for ‘root’@‘localhost’=password(‘新密码’);
      
  3. cd /usr/local/mysql/bin/

    $ sudo su
    # mysql_safe —init-file=/home/me/mysql-init &
    #mysql_safe —skip-grant-tables &
    #./mysql
    #flush privileges
    #update mysql.user  set authentication_string = password(‘你在文件中定义的新密码’),password_expired = ’N’ where user = ‘root’ and host = ‘localhost’
    #flush privileges;
    #quit;
    #./mysql -u root -p
    #输入你的新密码就好了
    
  4. 参考:B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems小节

相关文章:

  • 2022-12-23
  • 2021-07-16
  • 2021-08-14
  • 2022-01-19
  • 2022-12-23
  • 2021-06-16
  • 2021-12-14
  • 2022-01-01
猜你喜欢
  • 2021-06-19
  • 2021-11-25
  • 2021-12-10
  • 2022-02-23
  • 2022-12-23
  • 2021-11-20
  • 2022-01-24
相关资源
相似解决方案