简体   繁体   中英

MySQL error access denied

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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