Check if a database exist (MySQL) and if not create it in PHP

后端 未结 3 1100
生来不讨喜
生来不讨喜 2021-01-04 11:12

So i want to write a php script who checks in the data base (in localhost, user=\"root\", pass=\"\") \"data1\" exists, and if is not, create it. Please thanks for any help y

3条回答
  •  死守一世寂寞
    2021-01-04 11:55

    Send the following to mysql from your php code :
    CREATE DATABASE IF NOT EXISTS YourDB;
    Documentation : http://dev.mysql.com/doc/refman/5.0/en/create-database.html

提交回复
热议问题