shell
In a shell script, create a database if it does not exist
Key words and phrases:
mysql create database from bash script
mysql if database exists
automate creation of database if it doesn't already exist
PHP script
bash script if mysql database does not exist create
Description & Info:
Use the MySQL: SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database_name'
<?php
if (mysql_num_rows(mysql_query("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '". $dbname ."'"))) {
echo "Database $dbname already exists.";
}
else {
// go on and create the user, database, etc.
// create the user
