How to check if mysql database exists -


is possible check if (mysql) database exists after having made connection.

i know how check if table exists in db, need check if db exists. if not have call piece of code create , populate it.

i know sounds inelegant - quick , dirty app.

select schema_name information_schema.schemata schema_name = 'dbname' 

if need know if db exists won't error when try create it, use (from here):

create database if not exists dbname; 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -