Question

Locked out of MySQL

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

Subscribe
Share

Submit an 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.

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