mac mysql安裝后的操作
首次安裝MySQL時會提示你一個默認(rèn)密碼如:
2016-03-05T08:49:48.666137Z 1 [Note] A temporary password is generated for root@localhost:,ktbs,7wk/%Q ? ? ?If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual. ?這樣的語句。
加粗斜體的就是默認(rèn)的密碼,你就可以直接去phpMyAdmin登陸了,有的時候你在登陸的時候回提示,密碼過期(Your password has expired. To log in you must change it using a client that supports expired passwords)
這樣的話,所以你需要在終端做一下操作
1.進(jìn)入終端,輸入指令:cd /usr/local/mysql/bin/,進(jìn)入安裝目錄(安裝目錄可能會不同);
2.輸入指令:sudo su,進(jìn)入管理員權(quán)限(需要輸入mac的密碼);
3.輸入指令:./mysqld_safe --skip-grant-tables &,禁止mysql驗(yàn)證功能。此時mysql服務(wù)會自動重啟了;
這是命令行輸入后的效果

現(xiàn)在就可以用之前的密碼通過終端進(jìn)入MySQL了 使用命令如下:
可以先使用這個命令
mysql -uroot -p
如果提示以下錯誤:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
就通過這種方式打開MySQL:
4、mysql -uroot -h127.0.0.1 -p
你可以通過這個命令改密碼:
./mysqladmin -u root -p password 123
但是你可能也會遇見這樣的問題:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
意思是你沒有權(quán)限去改密碼
你可以直接用下面的命令就可以去修改密碼了:
5、mysql> SET PASSWORD = PASSWORD('new_password');
