mac mysql

1.点击mysql5.7下载

2.安装完成后:(记住最后一步分配的初始密码)

3.启动:可以在偏好设置中start/stop,亦可通过命令

    sudo /usr/local/mysql/support-files/mysql.server start

    sudo /usr/local/mysql/support-files/mysql.server stop

    sudo /usr/local/mysql/support-files/mysql.server restart

4.简化启动命令:

   A. touch .bash_profile

    B.在打开的profile中添加以下内容

    alias mysqlstart="sudo /usr/local/mysql/support-files/mysql.server start"

    alias mysqlstop="sudo /usr/local/mysql/support-files/mysql.server stop"

    alias mysqlrestart="sudo /usr/local/mysql/support-files/mysql.server restart"

    C.source .bash_profile

    D.通过 mysqlstart启动      mysqlstop停止    mysqlrestart 重启

5.如果忘记初始分配密码,请执行以下操作

sudo /usr/local/mysql/support-files/mysql.server stop

cd /usr/local/mysql/bin/

sudo su

 ./mysqld_safe --skip-grant-tables &

到此mysql的状态应该是running

 ./mysql

FLUSH PRIVILEGES;

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('新密码'); 

参考

你可能感兴趣的:(mac mysql)