mysql重設密碼
wulilideMacBook-Pro:bin wulili$ mysql start
ERROR 1045 (28000): Access denied for user 'wulili'@'localhost' (using Macpassword: NO) woooal-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";
Reading table
Database changed
mysql> update user set password=PASSWORD('12345678') where user="root";
ERROR 1054 (42S22): Unknown column 'password' in ' field list'
mysql> quit
Bye
3、重啟資料庫
wulilideMacBook-Prorootport-MacBook-Proj/files/filer/filer.
Shutting down MySQL
. 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 itsOracle 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 muststateet alter user 'root'@' localhost' identified by '12345678';
Query OK, 0 rows affected (0.01 sec)
mysql> flushprivileges;
mysql> show databases;
+--------------------+
| mysql |
|效能模式|
| sys
+----------------