Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does `sudo mysql` (without flag) do?

I am new to mysql. I assumed it would connect me as root but I am not sure it does that because when I then run create database hello; it says:

No connection. Trying to reconnect...
ERROR 1049 (42000): Unknown database 'hello'
ERROR: 
Can't connect to the server

(I expected it to just create the database)

I am on ubuntu 23, running mysql locally.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

sudo mysql will login you as root in your local mysql server. the error I am seeing is related to a different point

You try to create the database. Mysql fails with this error:

No connection. Trying to reconnect…

then tries to switch to the created database:

ERROR 1049 (42000): Unknown database ‘hello’
ERROR:
Can’t connect to the server

so you have to dig why you get this error about connection dropping. The error you get has nothing to do with the title of your question.
I expect nothing will change even if you log in as a user with rights

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading