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

Advertisements

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.

>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

Leave a ReplyCancel reply