跳轉(zhuǎn)鏈接
遠程連接MySQL:
mysql -u 用戶名 -h 遠程IP地址 -p
brew intall
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
iMac系統(tǒng)環(huán)境:mysql(5.7.17) install for mac(10.11.13)
環(huán)境設(shè)置及啟動數(shù)據(jù)庫:
brew install mysql echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile source ~/.profile 檢查一下mysql的運行狀態(tài) $ ps -ef | grep mysql 檢查mysql 版本號梆靖; mysql --version 查看 mysqld服務(wù)啟動時候返吻,配置文件的讀取順序: mysqld --verbose --help | grep -A 1 'Default options' 啟動mysql: $mysql.server start
Mac 關(guān)于Mysql的卸載:
如使用brew安裝:brew uninstall MySQL 或者 brew remove mysql
但是又有點怕某些東西沒有卸載完全影響到下一次的安裝(我第一次重裝就是這樣的)以下是完整一點的手動卸載:
sudo rm /usr/local/mysql sudo rm -rf /usr/local/mysql* sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm -rf /Library/PreferencePanes/My* rm -rf ~/Library/PreferencePanes/My* sudo rm -rf /Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm -rf /var/db/receipts/com.mysql.* 其實不同的安裝方式有些東西的存儲位置不一樣,刪除完檢查一下一些問文件是否刪除了测僵,沒有的話則刪除掉: /usr/local/Cellar 里的mysql文件 /usr/local/var 里的mysql文件 /tmp 里的mysql.sock, mysql.sock.lock, my.cnf文件 pid文件和err文件都在/usr/local/var/mysql里確保刪除了 brew安裝的安裝包存儲在/usr/local/Library/Cache/Homebrew也可以一并刪除 執(zhí)行brew cleanup
錯誤一:Error: The brew link step did not complete successfully
在brew執(zhí)行install mysql之后會出現(xiàn)一系列的安裝信息捍靠,出現(xiàn)一個Error,查看到了ERROR的內(nèi)容:
Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink lib/libmysqlclient.20.dylib /usr/local/lib is not writable. You can try again using: brew link mysql
~ brew link mysql
Linking /usr/local/Cellar/mysql/5.7.12...
Error: Could not symlink lib/libmysqlclient.20.dylib
/usr/local/lib is not writable. //這個文件夾不可寫
sudo chown -R $(whoami) /usr/local/lib/ Password: ? ~ brew link mysql Linking /usr/local/Cellar/mysql/5.7.12… 93 symlinks created
錯誤二:Can\’t open the mysql.plugin table.
ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxxiMac.local.pid). mysqld: Table 'mysql.plugin' doesn't exist [ERROR] Can\'t open the mysql.plugin table. Please run mysql_upgrade to create it. 解決方法: unset TMPDIR mysql_install_db --verbose --user=mysql --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql
/etc/my.cnf 配置文件信息
[mysqld_safe] log-error = /usr/local/var/mysql/logs/error.log [mysqld] datadir = /usr/local/var/mysql bind-address = 127.0.0.1 port = 3306 [client] socket = /tmp/mysql.sock
錯誤三:ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
方案一: jddeiMac:~ iosTest$ mysql.server stop Shutting down MySQL .. SUCCESS! jddeiMac:~ iosTest$ mysql.server start --skip-grant-tables Starting MySQL . SUCCESS! jddeiMac:~ iosTest$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 Homebrew 方案二: jddeiMac:tmp iosTest$ mysqld --skip-grant-tables & [1] 18745 jddeiMac:tmp iosTest$ 2017-03-29T10:04:00.209544Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-03-29T10:04:00.209815Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2017-03-29T10:04:00.209889Z 0 [Note] mysqld (mysqld 5.7.17) starting as process 18745 ...