I have a set of databases as below
mysql> show databases;
+------------------------+
| Database |
+------------------------+
| information_schema |
| sys |
| system |
| test |
When I try to access ‘test’ database using the master user I’m getting below error
mysql> use information_schema;
Database changed
mysql>
mysql>
mysql> use test;
ERROR 1049 (42000): Unknown database 'test'
mysql>
Why is this error generating ?
MySQL Version 5.7
2
Answers
Issue seems to be that the database was not properly created.
create database test;
Resolved the issue.
This does not strike me as a privilege issue. Otherwise, an error message should denote that as
ERROR 1044 (42000): Access denied for user xx to database xxx
. It’s more likely there is something wrong with the data file. To demonstrate, we can create a test database.Please also note, if you directly copy a database from a remote host to your current server’s mysql data directory, you are able to switch to the database, but you can not use its tables.
As you can see , in this case , as mysql server did not register the table of the remote copied database, querying the table returned an error.