Report this

What is the reason for this report?

Locked out of MySQL

Posted on October 16, 2019

Hi guys,

So, I’ve just tried to secure my mysql connection and put a password which I read was the right thing to do.

Having said that, now I can’t actually connect to MySQL using the following command

mysql

It says I don’t have access. I’m at a loss, what to do?

The good thing is, my applications are running



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.
0

Accepted Answer

Hi @Remdore,

Don’t worry, you can still enter your mysql like that

mysql -u root -p

That will connect you with your root user once you provide your password.

Having said that, if you don’t want to type in your password every single time, there is a solution to the problem as well. Create a file at the following location

touch ~/.my.cnf

In the file put the following

vi ~/.my.cnf
[mysql]
user=root
password=YourPAsswordHere

That should be enough for you to be able to enter your MySQL service just by typing mysql.

Regards, KDSys

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.