简体   繁体   中英

ERROR 1045 (28000): Access denied for user 'user'@'localhost'

I'm trying to log into MySQL on a remote server. I have ssh-ed into the server, and I am trying to access the server's local MySQL db.

I got the login credentials from the config file of a local application

mysql -u user -p

but when I login using the same password, I get

ERROR 1045 (28000): Access denied for user 'user'@'localhost' 

Details:

username: user
password: password
table   : table_name
host    : localhost

I have tried the same password a few times, but there must be something other than an incorrect password. I'm very confused, what am I doing wrong?

  1. get root privileges.

    sudo bash

  2. stop mysql server -- ubuntu example

    service mysql stop

  3. open mysql without checking passwords -- ubuntu example

    /usr/bin/mysqld_safe --skip-grant-tables &

  4. log in as root

    mysql --user=root mysql

  5. Enable privileges

    flush privileges;

  6. Change the password and grant any access you might need

    update user set Password=PASSWORD('password') WHERE User='username';

    GRANT ALL ON table_name.* TO 'username'@'localhost' ;

    flush privileges;

    exit ;

  7. Exit safe mode and restart

    kill cat /var/run/mysqld/mysqld.pid

    service mysql start

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