Access denied for user 'root' @ 'localhost' (using password: Yes) after password reset LINUX

I have MySQL installed on my Linux server, I forgot the password, so I went and changed it using the methods I found on the Internet. I have done the following:

/etc/init.d/mysql stop mysqld_safe --skip-grant-tables & mysql --user root mysql SELECT * FROM user; // I checked if I could access the user table or not update user SET password = PASSWORD('new_pass') WHERE user = 'root'; flush privileges; exit 

The update request changed the password since it showed me the number of rows affected and Query OK, etc.

Then I restarted mysql

 /etc/init.d/mysql stop /etc/init.d/mysql start 

Now that I am logged in with a new password

 mysql -u root -p new_pass 

it still gives me errors "ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: Yes)"

Is there something I am missing?

+8
linux mysql configuration
source share
10 answers

Actually, I examined the user table in the mysql database in more detail, it turned out that someone had edited the ssl_type field for the root user for SSL before me.

I edited this field and restarted mysql and it worked like a charm.

Thanks.

-one
source share

I managed to solve this problem by running this statement

 sudo dpkg-reconfigure mysql-server-5.5 

What will change the root password.

+17
source share

You can reset your MySQL database server password using the following five simple steps. Here are the commands that you need to enter for each step (login as root):

Step # 1: Stop the mysql service

 /etc/init.d/mysql stop 

Output:

 Stopping MySQL database server: mysqld. 

Step # 2: Start the MySQL server without a password:

 mysqld_safe --skip-grant-tables & 

Output:

 [1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started 

Step # 3: connect to mysql server using mysql client:

 mysql -u root 

Output:

 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> 

Step # 4: Setting a new root root password

 mysql> use mysql; mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit 

Step # 5: Stop the MySQL server:

 /etc/init.d/mysql stop 

Output:

 Stopping MySQL database server: mysqld STOPPING server from pid file /var/run/mysqld/mysqld.pid mysqld_safe[6186]: ended [1]+ Done mysqld_safe --skip-grant-tables 

Step # 6: Start the MySQL server and test it

 /etc/init.d/mysql start mysql -u root -p 
+8
source share

You must reset the password! steps for mac osx (tested and working) and ubuntu

Stop mysql

 $ sudo /usr/local/mysql/support-files/mysql.server stop 

Run it in safe mode:

 $ sudo mysqld_safe --skip-grant-tables 

(above line is the whole command)

This will be the current command until the process completes, so open another shell / terminal window, log in without a password:

 $ mysql -u root mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; 

Start mysql

 sudo /usr/local/mysql/support-files/mysql.server start 

your new password is "password".

+6
source share

I had the same problem. You should write mysql -u root -p

NOT mysql or mysql -u root -p root_password

+2
source share

I am facing the same problem, @ progrAmmar enlightens me, " examined the user table in the mysql database in more detail .

My problem is not ssl_type , not the first field: Host . I changed the value with

update user set Host='localhost' where User='root' and Host='%';

in the mysqld_safe --skip-grant-tables model mysqld_safe --skip-grant-tables .

Then it works well.

+1
source share

You may need to clear the plugin column for your root account. In my new installation, all root user accounts were set to unix_socket in the plugin column. This caused the root sql account to be blocked only for the unix root account, since only the system root could log in via the socket.

If you update user set plugin='' where User='root';flush privileges; , now you can log in to the root account from any localhost unix account (with password).

See this question and AskUbuntu answer for details .

+1
source share

On Mac OS, follow these steps:

Stop MySQL

$ sudo / usr / local / mysql / support-files / mysql.server stop Run it in safe mode:

$ sudo mysqld_safe --skip-grant-tables (above the line is the entire command)

This will be the current command until the process completes, so open another shell / terminal window, log in without a password:

$ mysql -u root

mysql> UPDATE mysql.user SET Password = PASSWORD ('password') WHERE User = 'root'; Start mysql

sudo / usr / local / mysql / support-files / mysql.server start your new password is "password".

+1
source share

In my case:

  • /etc/init.d/mysql stop
  • mysqld_safe --skip-grant-tables and

(in a new window)

  1. mysql -u root
  2. mysql> use mysql;
  3. mysql> update user set authentication_string = password ('password'), where user = 'root';
  4. mysql> privileges flush;
  5. mysql> quit
  6. /etc/init.d/mysql restart
0
source share

You can try this solution: -

In order for mysql to ask you for a password, you also need to specify -p-option: (try a space between -p and password)

 mysql -u root -p new_password 

MySQLl Access Denied

In the second link, someone commented on the same problem.

-one
source share

All Articles