1.安裝
brew install mysql
安裝后提示
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
安裝位置
/usr/local/Cellar/mysql/5.7.18_1
2.啟動MySQL
mysql.server start
3.配置文件及日志文件及相關路徑
/etc/my.cnf
/usr/local/var/mysql
/var/log/mysqld.log
4.完全卸載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
5.數(shù)據(jù)庫導入與導出
mysqldump --add-drop-table -uroot -p 數(shù)據(jù)庫名稱 > 導出文件.sql
mysql -h localhost -uroot -p 數(shù)據(jù)庫名稱 < 導入文件.sql