Method: 1. Execute the "SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = 'database name';" statement; 2. Execute the "show databases like 'database name';" statement.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
mysql query whether the database exists
Method 1:
Execute the following statement in mysql
SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '数据库名称';
Method 2:
Execute the following statement
show databases like '数据库名称';
Expand knowledge: Query whether the data table exists
show tables like 'table_name';
[Related recommendations: mysql video tutorial]
The above is the detailed content of How to query whether the database exists in mysql. For more information, please follow other related articles on the PHP Chinese website!