首頁 >資料庫 >mysql教程 >mysql重設密碼

mysql重設密碼

高洛峰
高洛峰原創
2016-12-01 13:27:491250瀏覽

mysql重設密碼

wulilideMacBook-Pro:bin wulili$ mysql start

ERROR 1045 (28000): Access denied for user 'wulili'@'localhost' (using Macpassword: NO) woo​​oal-fulBookoo su - root

1、吧mysql服務關閉

2、

 啟動mysqld_safe ,跳過啟動授權表。啟動時加上skip-grant-tables參數目的是在啟動mysql時不啟動grant-tables,授權表。這樣就可以修改root的密碼了。

# mysqld_safe --skip-grant-tables &

# mysqld_safe --skip-grant-tables &


wulilideMacBook-Pro:support-files root# find / -name mysqld_safeo:Noto dev/fd/4: Not a directory

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

wulilideMacBook-Pro:support-mysqld_safe

wulilideMacBook-Pro:support-mysqld_safe

wulilideMacBook-Pro:support-mysqld_safe

wulilideMacBook-Pro:support-filefiles root#my-57 .16-osx10.11-x86_64/bin/mysqld_safe --skip-grant-tables &

[1] 1397

wulilideMacBook-Pro:support-files root# 2016-11-30TilideMacsqling. '/usr/local/mysql/data/wulilideMacBook-Pro.local.err'.

2016-11-30T11:47:40.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/my/sql uroot -p

Enter password: 按下回車鍵

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

Your MySQL connection id is 2

Serveral 755.


Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights 資源demarks of their respective

owners.

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

12345678') where user="root"; 

ERROR 1046 (3D000): No database selected

mysql> use mysql;


Reading table

mysql> use mysql;

Reading table information for plehed 片🜥 > 你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 'pass' infidmm sed fidupdate 'list listd list password=password('12345678') where User='root';

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

my > ="root";

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

Rows matched: 1  Changed: 1  Warnings: 1

ed (0.00 sec)

mysql> quit

Bye

3、重啟資料庫

wulilideMacBook-Prorootport-MacBook-Proj/files/filer/filer.

Shutting down MySQL

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

. SUCCESS! 

[1]+  Done                    /usr/local/mysql-5.7.16-osx10.11-Macx86_64/isql-dc/5030m->11-Macx864/Book0 Pro:support-files root# mysql -u root -p  這裡密碼就是12345678了

Enter password: 


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

Your MySQL connect id is 483.

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

Oracle is a registered trademark of Oracle 和/or its

Oracle is a registered trademark of Oracle 和/or its

Oracle is a registered trademark of Oracle 和/or its55,a control.

owners.

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

:Pgmy> files root# 


mysql> use mysql;

ERROR 1820 (HY000): You muststate reset

ERROR 1820 (HY000): You muststateet  alter user 'root'@' localhost' identified by '12345678';

Query OK, 0 rows affected (0.01 sec)


mysql> flushprivileges;

mysql> show databases;

+--------------------+

| Database           |

+---------------- ----+

| information_schema |

| mysql              |

|效能模式|

| sys               

+----------------

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn