Mac Mysql忘记密码重置备忘

来源:互联网 发布:修改图片大小软件 编辑:程序博客网 时间:2024/05/18 17:58
  1. 1. 停止mysql服务,可以在偏好设置里停止,也可以用命令执行。

  2. 2. cd  /usr/local/mysql/bin/

  3. 3. sudo ./mysqld_safe -- skip-grant-tables, 这样mysql服务会启动

  4. 4. 新开一个终端,/usr/local/mysql/bin/mysql 无密码进入mysql

  5. 5. 选择数据库

    mysql>use mysql;

  6. mysql>show tables;
  7. mysql> describe user;
  8. | plugin                 | char(64)                          | NO   |     | mysql_native_password |       || authentication_string  | text                              | YES  |     | NULL                  |       || password_expired       | enum('N','Y')                     | NO   |     | N                     |       || password_last_changed  | timestamp                         | YES  |     | NULL                  |       || password_lifetime      | smallint(5) unsigned              | YES  |     | NULL                  |       || account_locked         | enum('N','Y')                     | NO   |     | N                     |       |+------------------------+-----------------------------------+------+-----+-----------------------+-------+
    6. 这里会发现这个表里其实没有password这一行,其实Mac下面的账户密码是authentication_string这一行跟其他版本不一样。
  9. 7. 设置新密码
    mysql> update user set authentication_string=password('1111') where user='root';
  10. mysql> flush privileges; 
0 0
原创粉丝点击