I have inherited a server that has mysql installed on it. I don't have the mysql password for any user, not even root (although I have the linux root password). Plus, I am only aware of one other user account besdies root, and that one does not have privileges to perform any action, not even SELECT.
I tried stopping the mysql servicw, restarting with the skip grant tables option, and just logging in without password:
service mysqld stop service mysqld start --skip-grant-tables & mysql -u root
But get the following error:
Access denied for user 'root'@'localhost' (using password: NO)
I then tried resetting the password:
mysqladmin -u root password 'newpw'
But that also gives an access denied error.
I also tried logging in as the other user (without pw) and executing the following command:
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
and got this error:
ERROR 1142 (42000): UPDATE command denied to user ''@'localhost' for table 'user'
I have also tried removing mysql and reinstalling, but I get the same errors.
Any suggestions?
In order to recover the password, you simply have to follow these steps: Stop the MySQL server process with the command sudo service mysql stop. Start the MySQL server with the command sudo mysqld_safe –skip-grant-tables –skip-networking & Connect to the MySQL server as the root user with the command mysql -u root.
In the mysql client, tell the server to reload the grant tables so that account-management statements work: mysql> FLUSH PRIVILEGES; Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.
Configuring a default root password for MySQL/MariaDB Use the following procedure to set a root password. To change the root password, type the following at the MySQL/MariaDB command prompt: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyN3wP4ssw0rd'; flush privileges; exit; Store the new password in a secure location.
try sudo dpkg-reconfigure mysql-server-5.5
and you will be asked for the new root password.
Replace 5.5 with your current mysql-server version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With