MySQL错误访问被拒绝 [英] MySQL error access denied

查看:93
本文介绍了MySQL错误访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Ubuntu 14.04 上配置 MySQL 服务器.安装后,它运行良好,无论是shell mysql 还是MysqlWorkbench.

在我重新启动系统后,一切都停止了.如果我尝试与 shell 连接,我会得到这个:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

我遇到任何用户都出现此错误...即使使用 --skip-grant-tables 选项,我也无权访问任何内容.来自工作台的连接测试也不起作用,尽管服务器似乎运行正常.

当我安装 mysql 服务器时,我被要求输入 root 密码,我选择了一个非常简单的密码,因为我将它用于调试环境,所以我认为这不是拼写错误的问题.

我想我已经尝试了所有可用的提示,但仍然无法访问服务器.

任何帮助将不胜感激.预先非常感谢您!!

编辑 1: 这是 my.cnf 的一部分

 [mysqld]## * 基本设置#用户 = mysqlpid-file =/var/run/mysqld/mysqld.pidsocket =/var/run/mysqld/mysqld.sock端口 = 3306basedir =/usr数据目录 =/var/lib/mysqltmpdir =/tmplc-messages-dir =/usr/share/mysql跳过外部锁定## 现在不是跳过网络,默认是只监听# localhost 更兼容且不那么安全.绑定地址 = 127.0.0.1

而且服务器似乎正在运行:

juan@Juancho:~$ sudo netstat -tap |mysqltcp 0 0 本地主机:mysql *:* ESCUCHAR 1158/mysqld

解决方案

这是官方文档,因为您的问题可能是由各种原因引起的.而且您的问题没有足够详细地描述您的问题.

http://dev.mysql.com/doc/refman/5.0/en/access-denied.html

我想引用文档中最常见的初学者错误"

<块引用>

确保服务器没有被配置为忽略网络连接或(如果您尝试远程连接)它具有未配置为仅在其网络接口上本地侦听.如果服务器以 --skip-networking 启动,它将不接受根本没有 TCP/IP 连接.如果服务器启动时--bind-address=127.0.0.1,它只会在loopback接口本地监听TCP/IP连接,不会接受远程连接.

<小时><块引用>

如果出现以下错误,则说明您正在使用不正确的root密码:

<块引用>

"shell> mysqladmin -u root -pxxxx ver 用户拒绝访问'root'@'localhost'(使用密码:YES)"

如果即使您没有指定一个密码,这意味着您在某些列表中列出了错误的密码选项文件.

<小时><块引用>

localhost 是本地主机名的同义词,也是如果您未指定主机,则客户端尝试连接的默认主机明确的.

为了避免在此类系统上出现此问题,您可以使用 --host=127.0.0.1显式命名服务器主机的选项.这将使 TCP/IP连接到本地 mysqld 服务器.您还可以通过以下方式使用 TCP/IP指定使用本地主机名的 --host 选项主持人.在这种情况下,必须在用户表中指定主机名服务器主机上的行,即使您正在运行客户端程序在与服务器相同的主机上.

希望对您有所帮助.

如果这不能解决您的问题,您可能只是输错了密码,所以这里是如何取回密码".

如果您刚刚设置了服务器,则很有可能在您的 bash 历史记录中获得它.要检查这一点,请输入 history 并搜索您的命令,在最好的情况下,它包含您的明文传递.

在大多数情况下,以上不是一个选项,要解决这个问题,您必须搜索您的系统维护用户(在位于/etc/mysql/debian.cnf 的 Debian 上),在那里您将看到用户名和维护用户的密码.使用该用户连接到您的数据库并使用 grant 命令更改用户的详细信息.

I'm trying to configure MySQL server on Ubuntu 14.04. After installing it, it worked fine, both shell mysql and MysqlWorkbench.

After I had the system rebooted everything stopped working. If I try to connect with the shell I get this:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I get this error with any user... Even with the --skip-grant-tables option I don't have access to anything. The connection test from the Workbench does not work either, although the server seems to be running properly.

When I was installing mysql server I was asked for a root password and I've chosen a very simple one since I'm using it for a debugging environment, so I don't think it's a misspelling issue.

I think I've tried all the tips available but still don't have access to the server.

Any help would be appreciate. Thank you very much in advance!!

EDIT 1: Here's part of the my.cnf

 [mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 127.0.0.1

And the server seems to be running:

juan@Juancho:~$ sudo netstat -tap | grep mysql
tcp        0      0 localhost:mysql         *:*                     ESCUCHAR    1158/mysqld     

解决方案

Here's the official documentation, as your problem can be caused by all sorts of things. And your question doesn't describe your issue in enough detail.

http://dev.mysql.com/doc/refman/5.0/en/access-denied.html

I'd like to cite the Documentation for the most common "beginner errors"

Make sure that the server has not been configured to ignore network connections or (if you are attempting to connect remotely) that it has not been configured to listen only locally on its network interfaces. If the server was started with --skip-networking, it will not accept TCP/IP connections at all. If the server was started with --bind-address=127.0.0.1, it will listen for TCP/IP connections only locally on the loopback interface and will not accept remote connections.


If you get the following error, it means that you are using an incorrect root password:

"shell> mysqladmin -u root -pxxxx ver Access denied for user 'root'@'localhost' (using password: YES)"

If the preceding error occurs even when you have not specified a password, it means that you have an incorrect password listed in some option file.


localhost is a synonym for your local host name, and is also the default host to which clients try to connect if you specify no host explicitly.

To avoid this problem on such systems, you can use a --host=127.0.0.1 option to name the server host explicitly. This will make a TCP/IP connection to the local mysqld server. You can also use TCP/IP by specifying a --host option that uses the actual host name of the local host. In this case, the host name must be specified in a user table row on the server host, even though you are running the client program on the same host as the server.

Hope this might be helpful for you.

If this does not solve your problem, you probably just mistyped your password, so here's "how to get it back".

If you just set up your server, there's a good chance you got it in your bash history. To check that, type history and search for your command which in the best case contains your cleartext pass.

Most of the times the above is not an option, to work around this you have to search for your system maintenance user (on Debian located in /etc/mysql/debian.cnf) in there you'll see the username and password of your maintenance user. Use that user to connect to your databse and change the details of your user with the grant command.

这篇关于MySQL错误访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆