Question

Access denied for installing MYSQL?

Posted October 25, 2014 14.5k views

I tried to follow this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu
To install the MYSQL database, but when I get to the command “sudo /usr/bin/mysqlsecureinstallation” and I try to enter my root password of the server, it keeps on tell me I have the wrong password. The error message is as below:

ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: YES)

I am sure the password I entered is correct.
Any one can provide some help here?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
3 answers

If you still have this problem, try resetting your password using the following steps.

Stop the MySQL Server. On your terminal run these commands:

sudo /etc/init.d/mysql stop

Then start the mysqld configuration. enter this command

sudo mysqld --skip-grant-tables &

Login to MySQL as root.

mysql -u root mysql

Replace YOURNEWPASSWORD with your new password!

UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; 
FLUSH PRIVILEGES; exit;

See if it works.
*NOT A VERY SECURE METHOD OF CHANGING/RESETTING PASSWORDS BUT IT SHOULD WORKS

edited by asb
  • Thanks for your help!
    I tried to follow the steps , but when I get to entering the command
    sudo mysqld --skip-grant-tables &
    I get error message: “ [Warning] Using unique option prefix keybuffer instead of keybuffer_size is deprecated and will be removed in a future release. Please use the full name instead.”

    What means by use the full name? Sorry for being so dump on this…

  • As the error says, you should use key_buffer_size instead of key_buffer. Edit /etc/mysql/my.cnf and replace key_buffer with key_buffer_size. Though that is a warning not an error so it shouldn’t affect anything right now but when the key_buffer option gets deprecated MySQL will most likely refuse to start because of an invalid config.

  • Thanks the problem is solved now!

MySQL root password is not the same as the server root password.

i followed the steps mentioned above but it does not work, i keep getting this error
*ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ *

Submit an Answer