简体   繁体   中英

When I try to log into MySQL via command line, keeps saying "unknown database 'magento2'"

When I try to log into MySQL via command line, keeps saying "unknown database 'magento2'"

Any ideas why? Tried as my username and root, getting the same message. If I can't log into mysql, how could I create a database to begin with of that name? So confused.

You should separate between your database application and a logical database. MySQL server is your database application / server.

When you're logging on to MySQL, you're choosing which logical database you would like to work with. A logical database is actually a container of objects such as tables, triggers, views, etc.

So when you see the error unknown database X , it's because you installed the MySQL server, but didn't create the logical database.

To see a list of all logical databases in your server, login to MySQL and run the command show databases;

To create your database, run the command create database magento2;

Now when you login to that database, it should be there and you can start creating your tables and query data from them.

I had the same issue and found that the database name was set in a cnf file. Perhaps you have something similar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM