MySQL Error Access denied for user root localhost

0 votes

./mysqladmin -u root -p 'redacted'
Enter password:

mysqladmin: connect to server at 'localhost' failed error:
'Access denied for user 'root'@'localhost' (using password: YES)'

How can I fix this?

May 4, 2020 in Database by kartik
• 37,520 points
18,337 views

1 answer to this question.

0 votes

Hello @kartik,

I did this to set my root password in initial set up of MySQL in OSx. Open a terminal.

sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'

Close the terminal and open a new terminal. And followings are worked in Linux, to set root password.

sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables

(sudo mysqld_safe --skip-grant-tables : This did not work for me in first time. But second try, out was success.)

Then login to MySQL

mysql -u root

FLUSH PRIVILEGES;

Now change the password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';

Restart MySQL:

sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server start
answered May 4, 2020 by Niroj
• 82,880 points

Related Questions In Database

0 votes
0 answers

SQLSTATE[HY000] [1045] Access denied for user 'username'@'localhost' using CakePHP

I'm new to CakePHP and PHP. While ...READ MORE

Aug 30, 2022 in Database by Kithuzzz
• 38,020 points
3,325 views
0 votes
0 answers

Access denied for user 'root@localhost' (using password:NO)

I wanted to run WordPress and it ...READ MORE

May 8, 2022 in Database by Kichu
• 19,050 points
1,535 views
0 votes
0 answers

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbname [duplicate]

I have this Java program: MySQLConnectExample.java import java.sql.*; import java.util.Properties; public ...READ MORE

Aug 21, 2022 in Database by Kithuzzz
• 38,020 points
2,101 views
0 votes
1 answer

Error:Import SQL dump into PostgreSQL database

Hello, Here is the command you are looking ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,880 points
5,027 views
0 votes
1 answer
0 votes
1 answer

How to empty a redis database?

Hello @kartik, You have two options: FLUSHDB - clears currently ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,880 points
848 views
0 votes
1 answer

How do I kill all the processes in Mysql “show processlist”?

Hello kartik, Mass killing operation saves time. Do it ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,880 points
2,494 views
0 votes
1 answer

Error Code: 2020. Lost connection to MySQL server during query

Hello @kartik, I got the same issue when ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,880 points
2,637 views
0 votes
1 answer

How to set SSL to Domain name for MYSQL database

Hello @ Lakshminarayanan, Yes, It is possible to setup ...READ MORE

answered Jul 9, 2020 in Database by Niroj
• 82,880 points
1,353 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP