How to check if a MySQL database exists?
Answers
Answered by
0
Is it possible to check if a (MySQL) database exists after having made a connection.
I know how to check if a table exists in a DB, but I need to check if the DB exists. If not I have to call another piece of code to create it and populate it.
I know this all sounds somewhat inelegant - this is a quick and dirty app.
Answered by
0
hey mate...
If database with the name 'dbname' doesn't exist, you get an empty set. If it does exist, you get one row.
Another best way of checking if a dabtabse exists is:
$mysql = mysql_connect("<your host>", "root", "");
if(mysql_select_db('<your db name>', $mysql)){
echo "databse exists";
}else{
echo "Databse does not exists";
}
hope it helpz~~~~~~~•••|¥¥¥¥~~~
RiaMariaS:
MARK AS BRAINLIEST
Similar questions