Check if the database exists in MySQL.

You can use the following statement in MySQL to determine if a database exists.

SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database_name';

If the query result is empty, it means the database does not exist; if the query result is not empty, it means the database exists.

bannerAds