MySQL——Mac安装使用mysql的正确方法

安装完成mysql之后会有一个有如下文字的弹框,


2016-08-04T06:30:31.497906Z 1 [Note] A temporary password is generated for root@localhost: ?TlmN7sjXT7w

If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.


一定要记下弹框中的密码,没有记下的话请删除重装。删除方法如下

1 sudo rm /usr/local/mysql

2 sudo rm -rf /usr/local/mysql*

3 sudo rm -rf /Library/StartupItems/MySQLCOM
4 sudo rm -rf /Library/PreferencePanes/My*
5 vim /etc/hostconfig (and removed the line MYSQLCOM=-YES-)
6 rm -rf ~/Library/PreferencePanes/My*
7 sudo rm -rf /Library/Receipts/mysql*
8 sudo rm -rf /Library/Receipts/MySQL*
9 sudo rm -rf /var/db/receipts/com.mysql.*



安装完mysql 之后,登陆以后,不管运行任何命令,总是提示这个
mac mysql error You must reset your password using ALTER USER statement before executing this statement.



所以我们要初始化密码,下面是初始化密码的步骤:

step 1: SET PASSWORD = PASSWORD('your new password');
step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

step 3: flush privileges;


完成以上三步退出再登,使用新设置的密码就行了,以上除了红色的自己修改成新密码外,其他原样输入即可


版权声明:本文为gaodeying123原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。