访问被拒绝的MYSQL错误1045 [英] Access Denied for MYSQL ERROR 1045
问题描述
我刚得到一个新的Macbook Pro(OS X 10.8.2),并尝试在其上安装mysql.到目前为止,我已经能够安装它,但无法获得root用户访问权限(或任何与此相关的用户).我计划将其用于Python
,在另一台计算机上,我仅使用MYSQL(不使用MAMP),并且我希望保持这种方式.
I just got a new macbook pro (OS X 10.8.2) and am attempting to get mysql set up on it. So far I've been able to get it installed but I cannot get my root user access (or any user for that matter). I plan on using this for Python
, on my other computer I only use MYSQL (no MAMP) and I prefer to keep it that way.
作为参考,我做了以下工作:
For reference, I did the following:
$ alias mysql=/usr/local/mysql/bin/mysql
$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
$ alias mysqladmin=/usr/local/mysql/bin/mysqladmin
$ alias mysql=/usr/local/mysql/bin/mysql
$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
$ alias mysqladmin=/usr/local/mysql/bin/mysqladmin
当我输入mysql
或mysql -u root -p
时,它会显示以下信息:
When i enter mysql
or mysql -u root -p
it gives me this:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
或
ERROR 1045 (28000): Access denied for user 'jmitch'@'localhost' (using password: NO)
取决于我使用的措词
ERROR 1045 (28000): Access denied for user 'jmitch'@'localhost' (using password: NO)
Depending on which phrasing I use
MYSQL在我的系统偏好设置中运行.谢谢您的帮助.
MYSQL is running in my system preferences. Thank you for your help.
推荐答案
也许更新程序包时,更新程序会覆盖根密码.
Maybe updating the package the updater overwrote the root password.
要还原它:
停止mysqld守护进程.
Stop mysqld deamons.
$ sudo service mysqld stop
转到mysql/bin目录
Go to mysql/bin directory
$ cd /usr/bin
使用以下选项启动mysql守护进程:
Start a mysql deamon with this option:
$ sudo mysqld_safe --skip-grant-tables
打开另一个终端并打开mysql会话以执行此操作:
Open another terminal and open a mysql session to execute this:
$ mysql
mysql> use mysql;
see Note1 below for next line.
mysql> UPDATE user SET password=PASSWORD('YOUR_NEW_PASSWORD_HERE') WHERE user = 'root';
mysql> exit;
现在终止mysqld_safe进程并正常重启mysqld:
Now kill the mysqld_safe process and restart mysqld normally:
$ sudo service mysqld start
Note1: password
是5.7版之前的表mysql.user
中的列名.之后变成authentication_string
.相应地更改您的更新声明.
Note1: password
is the column name in table mysql.user
prior to version 5.7. After which it became authentication_string
. Change your update statement accordingly.
这篇关于访问被拒绝的MYSQL错误1045的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!