Mac安装MySQL

  1. 下载mysql for mac: https://dev.mysql.com/downloads/mysql/
  2. 双击mysql-5.7.17-macos10.12-x86_64.dmg进行解压, 双击mysql-5.7.17-macos10.12-x86_64.pkg进行安装

img

  1. Continue -> Continue, Agree -> Install -> 输入管理员密码
  1. 记录下来弹窗中的密码

img

  1. 进入系统偏好设置, 找到mysql, 启动服务

img

  1. 将mysql的命令添加到系统中

    1) 进入/usr/local/mysql/bin,查看此目录下是否有mysql

    2) 执行vim ~/.bash_profile

    在该文件中添加mysql/bin的目录
    

PATH=$PATH:/usr/local/mysql/bin

添加完成后,按esc,然后输入wq保存。 (3).最后在命令行输入source ~/.bash_profile

  1. 通过mysql -uroot -p登录mysql, 输入之前保存的密码
  2. 重置mysql初始密码

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');

参考文章:

mac安装mysql的两种方法: http://www.jianshu.com/p/fd3aae701db9

MySql卸载

一般手动删除:

sudo rm -rf /usr/local/mysql

sudo rm -rf /usr/local/mysql*

sudo rm -rf /Library/StartupItems/MySQLCOM

sudo rm -rf /Library/PreferencePanes/My*

sudo 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.*

results matching ""

    No results matching ""