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.数据库导入与导出
mysqldump --add-drop-table -uroot -p 数据库名称 > 导出文件.sql
mysql -h localhost -uroot -p 数据库名称 < 导入文件.sql