OS: ubuntu 16.04 message: Error: Access denied for user ‘root’@‘localhost’ (using password: YES)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Heya,
If MySQL was configured properly, you should be able to get the password from the
/root/.my.cnf
file.Alternatively, if that file is not there, and If you have forgotten your MySQL root password, you will need to reset it. The process for resetting the MySQL root password varies depending on your operating system and the version of MySQL you are using. Below are general steps to reset the MySQL root password:
Stop MySQL Server: First, stop the MySQL server. The process to stop MySQL depends on your operating system.
Start MySQL in Safe Mode: Start the MySQL server in safe mode with the
--skip-grant-tables
option. This will allow you to log in to the MySQL server without a password as the root userConnect to MySQL: Open a new terminal or command prompt and connect to the MySQL server as the root user without a password:
Change the Root Password: Now that you are connected to the MySQL server, you can change the root password using SQL queries. Replace
'new_password'
with the desired new password:Note: In MySQL 5.7 and later versions, the
PASSWORD
function was deprecated in favor of usingmysql_native_password
. You can usemysql_native_password
like this:Once you’ve completed these steps, your MySQL root password should be changed to the new password you specified. Make sure to use the new password when connecting to the MySQL server as the root user in the future.