What are the steps to create a new database using MySQL and PHP?

The 4 main steps used to create a new MySQL database in PHP are given below:

  • A connection establishment is done to the MySQL server using the PHP script.
  • The connection is validated. If the connection is successful, then you can write a sample query to verify.
  • Queries that create the database are input and later stored into a string variable.
  • Then, the created queries will be executed one after the other.