MYSQL 错误 1045 拒绝访问

2024-04-16数据库问题
7

本文介绍了MYSQL 错误 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$别名mysqladmin=/usr/local/mysql/bin/mysqladmin

当我输入 mysqlmysql -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'(使用密码:YES)

ERROR 1045 (28000): Access denied for user 'jmitch'@'localhost' (using password: NO)取决于我使用的措辞

MYSQL 正在我的系统首选项中运行.感谢您的帮助.

MYSQL is running in my system preferences. Thank you for your help.

推荐答案

可能是更新包更新程序覆盖了 root 密码.

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

注1: 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 拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

MySQL GROUP BY DateTime +/- 3 秒
MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)...
2024-04-16 数据库问题
14