Mac Mysql忘记密码重置备忘

  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; 
  11. 
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值