1. 程式人生 > >macbook之brew安裝mysql

macbook之brew安裝mysql

macbook的mysql意外無法正常啟動

sudo mysql.server start
Password:
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/niuyufudeMacBook-Pro.local.pid).


tail -n 100 /usr/local/var/mysql/niuyufudeMacBook-Pro.local.err


2015-07-06 11:26:14 542 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.


試過很多方法總是無法解決問題。
所以只能重新安裝來解決。因為剛剛使用macbook所以會有很多各種各樣的問題發生,所以只能把問題記錄下來下次快速解決這個問題了。


如果想重新安裝mysql必須先解除安裝老mysql安裝檔案。

brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
sudo rm -rf /usr/local/var/mysql


下面開始重新安裝mysql,第二句意思是設定mysql為開機啟動專案。
brew install mysql
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
mysql.server start

mysql安裝完畢。下面配置密碼資訊;
mysql -uroot
select user,password,host from mysql.user;
delete from mysql.user where user='';
delete from mysql.user where host='::1';
set password for [email protected]=password('123456');
GRANT ALL PRIVILEGES ON *.* TO 'miaohr'@'%'  IDENTIFIED BY '123456';
flush privileges;

如果想修改mysql的配置,在/usr/local/etc下建立一個my.cnf,例如增加log
[mysqld]
general-log
general_log_file = /usr/local/var/log/mysqld.log

mysql.server restart


好了。以上算是比較全的使用brew安裝mysql的步驟了。




參考資料:
http://www.cnblogs.com/iosdev/archive/2012/09/12/2681917.html
http://segmentfault.com/q/1010000000475470
http://blog.csdn.net/qdujunjie/article/details/30492199
https://idoseek.com/143