-
1. 停止mysql服务,可以在偏好设置里停止,也可以用命令执行。
-
2. cd /usr/local/mysql/bin/
-
3. sudo ./mysqld_safe -- skip-grant-tables, 这样mysql服务会启动
-
4. 新开一个终端,/usr/local/mysql/bin/mysql 无密码进入mysql
-
5. 选择数据库
mysql>use mysql;
-
mysql>show tables;
-
mysql> describe user;
-
6. 这里会发现这个表里其实没有password这一行,其实Mac下面的账户密码是authentication_string这一行跟其他版本不一样。| 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 | | +------------------------+-----------------------------------+------+-----+-----------------------+-------+
-
7. 设置新密码
mysql>
update user set authentication_string=password('1111') where user='root'; -
mysql> flush privileges;
-
Mac Mysql忘记密码重置备忘
最新推荐文章于 2024-09-14 15:21:37 发布