mysql重置密码

mysql重置密码

wulilideMacBook-Pro:bin wulili$ mysql start

ERROR 1045 (28000): Access denied for user ‘wulili’@’localhost’ (using password: NO)

wulilideMacBook-Pro:bin wulili$ su – root

1、吧mysql服务关闭

2、

 启动mysqld_safe ,跳过启动授权表。启动时加上skip-grant-tables参数目的是在启动mysql时不启动grant-tables,授权表。这样就可以修改root的密码了。

# mysqld_safe –skip-grant-tables &

wulilideMacBook-Pro:support-files root# find / -name mysqld_safe

find: /dev/fd/3: Not a directory

find: /dev/fd/4: Not a directory

/usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe

wulilideMacBook-Pro:support-files root# /usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe –skip-grant-tables &

[1] 1397

wulilideMacBook-Pro:support-files root# 2016-11-30T11:47:40.6NZ mysqld_safe Logging to ‘/usr/local/mysql/data/wulilideMacBook-Pro.local.err’.

2016-11-30T11:47:40.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

mysql -uroot -p

Enter password: 按下回车键

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 2

Server version: 5.7.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

mysql> update user set password=PASSWORD(‘12345678’) where user=”root”; 

ERROR 1046 (3D000): No database selected

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set password=PASSWORD(‘12345678’) where user=”root”; 

ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’

mysql> update user set passwd=PASSWORD(‘12345678’) where user=”root”; 

ERROR 1054 (42S22): Unknown column ‘passwd’ in ‘field list’

mysql> update user set password=password(‘12345678′) where User=’root’;

ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’

mysql> update user set authentication_string=password(‘12345678’) where user=”root”;

Query OK, 1 row affected, 1 warning (0.01 sec)

Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

降重鸟 降重鸟

要想效果好,就用降重鸟。AI改写智能降低AIGC率和重复率。

降重鸟 113 查看详情 降重鸟

mysql> quit

Bye

3、重启数据库

wulilideMacBook-Pro:support-files root# /usr/local/mysql/support-files/mysql.server restart

Shutting down MySQL

..2016-11-30T11:58:22.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/wulilideMacBook-Pro.local.pid ended

 SUCCESS! 

Starting MySQL

. SUCCESS! 

[1]+  Done                    /usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe –skip-grant-tables

wulilideMacBook-Pro:support-files root# mysql -u root -p  这里密码就是12345678了

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 4

Server version: 5.7.16

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

mysql> quit

Bye

wulilideMacBook-Pro:support-files root# 

mysql> use mysql;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql>  alter user ‘root’@’localhost’ identified by ‘12345678’;

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;

+——————–+

| Database           |

+——————–+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+——————–+

4 rows in set (0.00 sec)

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/424093.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年11月7日 10:46:47
下一篇 2025年11月7日 10:55:53

相关推荐

发表回复

登录后才能评论
关注微信