在OS X

时间:2015-11-19 19:24:05

标签: mysql macos

我刚刚通过MySQL Package Installer安装了MySQL。 安装完成后,显示以下消息:

2015-11-19T21:16:59.224430Z 1 [Note] A temporary password is generated for root@localhost: qXkd%pqb)6z3

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

然后我尝试使用Sequel Pro登录 127.0.0.1 / root /#&lt ;; Ay。

这就是结果:

Your password has expired. To log in you must change it using a client that supports expired passwords.

这是MySQL WorkBench的结果

Your connection attempt failed for user 'root' from your host to server at 127.0.0.1:3306:
  Your password has expired. Your instance of Connector/C++ is not linked against mysql client library that allows to change it. resetting of an expired password. To resolve this, you either need to change the password with mysql client that can do it or rebuild your instance of Connector/C++ against mysql client library that supports resetting of an expired password.

Please:
1 Check that mysql is running on server 127.0.0.1
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the root has rights to connect to 127.0.0.1 from your address (mysql rights define what clients can connect to the server and from which machines) 
4 Make sure you are both providing a password if needed and using the correct password for 127.0.0.1 connecting from the host address you're connecting from

所以我试过

1)

     `cd /usr/local/mysql/bin`
      ./mysqladmin -u root password 'password'
      mysqladmin: connect to server at 'localhost' failed
      error: 'Access denied for user 'root'@'localhost' (using password: NO)'

2)

./mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

3)

 /usr/local/mysql/bin/mysqladmin -u root password NEW_PASSWORD_HERE
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

4)

cd /usr/local/mysql/bin/
MacBook-Pro-de-nunito:bin nunito$ ./mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 85
Server version: 5.7.9

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> update user set password=PASSWORD("NEW_PASSWORD_HERE") where User='root';
ERROR 1046 (3D000): No database selected
mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> USE mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> UPDATE user SET password=PASSWORD("NEWPASSWORD") WHERE User='root';
ERROR 1046 (3D000): No database selected
mysql> 

5)

 ./mysql -u root -h 127.0.0.1 -p
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

2 个答案:

答案 0 :(得分:3)

在第4点)

SET PASSWORD = PASSWORD('new_password');
use mysql;
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');

答案 1 :(得分:1)

使用ps au | grep mysqld找出运行mysql服务器的用户。 {}向所述用户sudo并运行update user set password=PASSWORD("NEW_PASSWORD_HERE") where User=user()。希望有所帮助。