我已经坚持了好几天。我已经安装了mysql。什么对我有效,进入mysql ..
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
$(brew --prefix mysql)/bin/mysqld_safe --skip-grant-tables --skip-networking
mysql -u root // or just mysql
现在我进入了。根据查询结果,我已经成功更改了'root'@'localhost'的密码。
mysql> select host, user, authentication_string from user;
+-----------+------------------+------------------------------------------------------------------------+
| host | user | authentication_string |
+-----------+------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root | pissword |
+-----------+------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)
但是,退出该过程并正常启动服务器后,我仍然无法访问mysql。
mysqladmin -u root shutdown
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysql -u root -ppissword
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
也许我可以检查日志或其他我不知道的东西。请帮忙。
答案 0 :(得分:0)
我认为您更改密码的方式存在问题。正确的语法是
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypass');
别忘了在那之后刷新特权:
FLUSH PRIVILEGES;
问题是,在authentication_string
列中,您将拥有密码的哈希,而不是原始密码。这就是PASSWORD
函数的作用。