SELECT SCHEMA_NAME
FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'DBName'
If you just need to know if a db exists so you won’t get an error when you try to create it, simply use (From here):
CREATE DATABASE IF NOT EXISTS DBName;
More Related Contents:
- Authentication plugin ‘caching_sha2_password’ cannot be loaded
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- Do different databases use different name quote?
- Is there a MySQL option/feature to track history of changes to records?
- Binary Data in MySQL [closed]
- Using an Alias in SQL Calculations
- Can a table field contain a hyphen?
- Adding a leading zero to some values in column in MySQL
- Auto Generate Database Diagram MySQL [closed]
- How can I modify the size of column in a MySQL table?
- MySQL InnoDB foreign key between different databases
- View’s SELECT contains a subquery in the FROM clause
- MySQL : Multiple row as comma separated single row
- How to re-sync the Mysql DB if Master and slave have different database incase of Mysql replication?
- Case statement in MySQL
- Export a MySQL Database to SQLite Database
- How to connect to MySQL from the command line
- How to find out the MySQL root password
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- How to display open transactions in MySQL
- MySQL query, MAX() + GROUP BY
- How to schedule a stored procedure in MySQL
- What’s the best way to migrate a Django DB from SQLite to MySQL?
- Easiest way to copy a table from one database to another?
- What are the differences between the BLOB and TEXT datatypes in MySQL?
- Native JSON support in MYSQL 5.7 : what are the pros and cons of JSON data type in MYSQL?
- Foreign key constraints: When to use ON UPDATE and ON DELETE
- How to Get True Size of MySQL Database?
- MySQL: Computed Column
- How do I make a MySQL database run completely in memory?