Report this

What is the reason for this report?

Error Connecting to MySQL as Root User with 1-click LAMP

Posted on November 10, 2020

Using the root MySQL password from /root/.digitalocean_password I am not able to log in using root. Using DBeaver, ssh connection and the tunnel connect is working correctly. I get the error “Access denied for user ‘root’@‘localhost’”

Is there something else I need to do?



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.

Hi there @geoffAU,

What is the exact command that you are using? Note that you need to specify the -p flag so that you could get prompted for a password:

  1. mysql -u root -p

Another thing that you could do is add your MySQL password to your ~/.my.cnf file so that you don’t have to enter the password each time as described here.

To do so follow these steps here:

  • Create the file:
  1. touch ~/.my.cnf
  • Give it secure permissions:
  1. chmod 600 ~/.my.cnf
  • Using your favorite text editor edit the file:
  1. nano ~/.my.cnf
  • And add the following configuration
[client]
user=root
password=YOUR_MYSQL_PASSWORD
  • Save and exit

Then you will be able to login to MySQL by just running mysql.

Regards, Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.