一、mac下安裝MySQL數據庫
1.下載MySQL數據庫
下載地址:訪問MySQL的官網http://www.mysql.com/downloads/ ,進行下載。
進入MySQL的下載界面(http://www.mysql.com/downloads/mysql/)
下載x86,64bit的dmg文件:直接選擇最下面的“No thanks,just take me to downloads!”
2.安裝MySQL數據庫
打開MySQL安裝包后,點擊安裝主程序pkg文件。
3.啟動MySQL數據庫
打開MYSQL數據庫文件方式,在系統偏好設置中打開,點擊MySQL,start mysql server ,即可啟動MySQL。
4.終端登錄MySQL數據庫:
1
|
mysql -u root -p |
回車,默認密碼為空。出現password后回車即可。
二、安裝數據庫后發現忘記了數據庫密碼
1.首先關閉MySQL數據庫
系統偏好設置中關閉MySQL,stop mysql server
2.進入安全模式
1
2
3
4
5
6
7
8
9
|
? bin sudo su Password : Sorry, try again. Password : sh-3.2# ./mysqld_safe --skip-grant-tables & [1] 3477 sh-3.2# 2017-06-27T08:32:37.6NZ mysqld_safe Logging to '/usr/local/mysql-5.7.18-macos10.12-x86_64/data/localhost.err' . 2017-06-27T08:32:37.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/ local /mysql-5.7.18-macos10.12-x86_64/data sh-3.2# |
3.重新啟動一個終端
1
2
3
4
5
6
7
8
9
10
|
~ mysql -u root -p Enter password : Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 16 Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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. |
4.輸入命令
1
2
|
mysql> FLUSH PRIVILEGES ; Query OK, 0 rows affected (0.06 sec) |
5.重新設置密碼
1
2
|
mysql> SET PASSWORD FOR root@ 'localhost' = PASSWORD ( 'root' ); Query OK, 0 rows affected, 1 warning (0.02 sec) |
6.再次輸入命令
1
2
|
mysql> FLUSH PRIVILEGES ; Query OK, 0 rows affected (0.00 sec) |
以上所述是小編給大家介紹的mac下安裝mysql忘記密碼的修改方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網站的支持!
原文鏈接:http://www.2cto.com/database/201706/651808.html