简体   繁体   English

MySQL错误访问被拒绝

[英]MySQL error access denied

I'm trying to configure MySQL server on Ubuntu 14.04 . 我正在尝试在Ubuntu 14.04上配置MySQL服务器 After installing it, it worked fine, both shell mysql and MysqlWorkbench. 安装后,无论是外壳mysql还是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. 任何用户都会遇到此错误...即使使用--skip-grant-tables选项,我也无权访问。 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. 当我安装mysql服务器时,我被要求输入root密码,并且选择了一个非常简单的密码,因为我将其用于调试环境,因此我认为这不是一个拼写错误的问题。

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 编辑1:这是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 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. 如果服务器以--skip-networking启动,则它将完全不接受TCP / IP连接。 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. 如果服务器以--bind-address = 127.0.0.1启动,它将仅在环回接口上本地侦听TCP / IP连接,并且不接受远程连接。


If you get the following error, it means that you are using an incorrect root password: 如果收到以下错误,则表明您使用的root密码不正确:

"shell> mysqladmin -u root -pxxxx ver Access denied for user 'root'@'localhost' (using password: YES)" “ shell> mysqladmin -u root -pxxxx ver用户'root'@'localhost'的访问被拒绝(使用密码:是)”

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. 为避免在此类系统上出现此问题,可以使用--host = 127.0.0.1选项来显式命名服务器主机。 This will make a TCP/IP connection to the local mysqld server. 这将建立与本地mysqld服务器的TCP / IP连接。 You can also use TCP/IP by specifying a --host option that uses the actual host name of the local host. 您还可以通过指定--host选项来使用TCP / IP,该选项使用本地主机的实际主机名。 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. 如果您只是设置服务器,那么很有可能在bash历史记录中找到了它。 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. 在大多数情况下,上述都不是一种选择,要解决此问题,您必须搜索系统维护用户(在/etc/mysql/debian.cnf上的Debian上),您将在其中看到用户名和密码维护用户。 Use that user to connect to your databse and change the details of your user with the grant command. 使用该用户连接到您的数据库,并使用grant命令更改用户的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM