Tag Archives: MySQL database problems and summary

MySQL appears: ERROR 1049 (42000): Unknown database’XXX’ solution

The problem
Remember that when you installed MySQL database, you typed it from the command line

mysql -u root -p password

When I entered the command today, I found that it was incorrect, and I was asked to enter the password again, and then returned

“ERROR 1049 (42000): Unknown database '123'”

The figure shows

The error message is that you don’t know the 123 database, meaning that the password after -p represents the database name. But the argument after -p is supposed to mean password, which is weird.
To solve
So I went through the blog that I summarized earlier and found that the statement looked like this

mysql -u root -p123

can see that -p and password are linked together, there is no space between them
and then log in naturally!!
Then I looked at a wave and I found:
-U can be followed by the user name or a space, but the password must not be followed by a space.
if Spaces are added, mysql will assume that the last one is a library name.
we can look at the correct statement:

(1)mysql -u root -p123

(2)mysql -uroot -p123