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;
Related Posts:
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- How do I restore a dump file from mysqldump?
- How do I quickly rename a MySQL database (change schema name)?
- Authentication plugin ‘caching_sha2_password’ cannot be loaded
- Create a new database with MySQL Workbench
- How to get size of mysql database?
- 1052: Column ‘id’ in field list is ambiguous
- 1052: Column ‘id’ in field list is ambiguous
- difference between primary key and unique key
- MySQL > Table doesn’t exist. But it does (or it should)
- How to create a foreign key in phpmyadmin
- importing a CSV into phpmyadmin
- Is there a Profiler equivalent for MySql?
- How to do a batch insert in MySQL
- SQL – IF EXISTS UPDATE ELSE INSERT INTO
- MySQL: Cloning a MySQL database on the same MySql instance
- Error: Duplicate entry ‘0’ for key ‘PRIMARY’
- Data is not constantly loading from custom wordpress table
- What’s a good strategy for planning WordPress DB growth?
- How do I load a sql.gz file to my database? (importing)
- Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
- MySQL ERROR 1290 (HY000) –secure-file-priv option
- Case statement in MySQL
- mysql Foreign key constraint is incorrectly formed error
- mysql: SOURCE error 2?
- How to avoid MySQL ‘Deadlock found when trying to get lock; try restarting transaction’
- MySQL foreach loop
- MySQL IF NOT NULL, then display 1, else display 0
- Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)
- MySQL Calculate Percentage
- Repair all tables in one go
- Best way to test if a row exists in a MySQL table
- MySQL Error 1215: Cannot add foreign key constraint
- How to use the keyword ‘references’ in MySQL?
- The MySQL alternatives: Do Percona Server and MariaDB work well with WordPress, and do they make WordPress go better?
- What are the recommended database permissions for WordPress?
- How can I find the source of slow queries in WordPress?
- Resetting comment count
- $wpdb and MySQL Create Trigger
- Changing user_nicename
- WordPress will not operate correctly
- importing data from non-wordpress mysql db
- Error: MySQL shutdown unexpectedly. XAMPP local conf running WordPress
- if statement on database query
- How to execute mulitple statement SQL queries using $wpdb->query?
- Database with mixed collation (utf8mb4 & utf8_general_ci)
- Split a database will improve performance?
- Is it good practice to use wpdb->query() function?
- Migrating database / content of non-CMS site to WordPress
- How to Query Database for posts with certain Taxonomy Term
- Delete all post meta except featured image Using SQL
- Error while importing database
- How do I find which articles are missing a featured image in The WordPress database?
- Can I restart MySQL engine when WordPress website is live?
- Error: MySQL shutdown unexpectedly [closed]
- Why my wordpress loopback traffic while socket is setup?
- How to remove /year/month from uploaded medias?
- new multisite, old db
- Call to undefined function get_user_meta() – trying to access data in MySQL from custom fields
- Not connecting to database in file with multiple MySQL connections
- Defining the same price to all WooCommerce Products
- Have working sql query… trying to adjust it to use $wpdb
- creating new field on mysql
- Database Structure on Different Servers
- How to get INSERT errors from $wpdb?
- SQL query to set posts in bulk based on the post content
- Export Yoast Keywords from MySQL/phpMyAdmin
- Same database; different WordPress
- How to fetch all meta_key and meta_value using post_id wihout duplication of post meta using sql query
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Fetch a single row from a custom table for to a given ID
- Database create or redirect
- Upgrade DB Loop – WordPress DB Version Conflict
- Button writing to MYSQL database
- How to escape percentage sign(%) in sql query with $wpdb->prepare?
- MySQL ‘duplicate entry’ error
- Performing CRUD operations on front end in wordpress
- What is my error trying to create a new table in the database?
- Deleted products from woocommerce are still in the database
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- Using wpdb to connect to a different database is not working
- How to show result of sql query in a page?
- Why can’t i come back to older working version of php after ugrade with error log on php 7.2 and 7.3
- Insert data from form to database
- How can I get $wpdb to show MySQL warnings?
- Populate custom post type/custom fields from an external database
- CONCAT_WS in custom sql query
- How to extract some part of WordPress full source code
- Query does not filter duplicate _sku numbers
- Ordering topics by most replies in X days using MYSQL statement
- MySQL Select within WP Page template
- two wordpress sites, two themes, one database, same content
- wp_postmeta – lot of meta fields
- Running WordPress from MySQL Cluster with HAPRoxy
- Custom query_posts() parameter
- Delete posts with word count less than x number of words
- MySQL: get post_tag items that are tags (not SEO keywords)
- $wpdb->get_var returns 0
- mysqldump throws: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)