Create a database
The CREATE DATABASE statement is used for creating databases in MySQL.
- Before creating a database, we first need to connect to the database server
Header // prevent Chinese garbled characters $conn=mysqli_connect("localhost", "root", ""); if (! $conn ) { diemysqli_connect_error()); // If the connection fails, output a message and exit the current script }
- After connecting the database, we can use the CREATE DATABASE statement to create one, and in the following code we will create a database named Myshop.
/* Create a database */ $sql = "CREATE DATABASE myshop";
So we create a database, run, we can open our database to see if this has been created successfully, here I use WAMP integrated MySQL database, the database address is http://127.0.0.1:8080/ phpMyAdmin, after opening, we will see the following interface: On the left is a list of our database, in this list, we can see that we have just created the Myshop this database has been created.
01.php and MySQL