配置MySQL环境

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容