Collections:
Creating a New Database in MySQL
How To Create a New Database in MySQL?
✍: FYIcenter.com
A database in a MySQL server is a logical container used to group tables and other data objects together as a unit. If you are the administrator of the server, you can create a new databases using the CREATE DATABASE statements with MySQL client interface programs.
If you want to create a new database with a PHP script, you can still use deprecated function, mysql_create_db(). But it's better use the mysql_query($sql,$con) function to create new databases. The tutorial exercise below shows you how to create a database called "fyi":
<?php
$con = mysql_connect('localhost:8888', 'dev', 'iyf');
$sql = 'CREATE DATABASE fyi';
if (mysql_query($sql, $con)) {
print("Database fyi created.\n");
} else {
print("Database creation failed.\n");
}
mysql_close($con);
?>
If you run this script, you will get something like this:
Database fyi created.
⇒ Failed to Create a Database in MySQL
⇐ List All Existing Databases in MySQL
2017-11-11, 2097🔥, 0💬
Popular Posts:
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
How To Create a Dynamic Cursor with the DYNAMIC Option in SQL Server Transact-SQL? If the underlying...
What are DDL (Data Definition Language) statements for tables in SQL Server? DDL (Data Definition La...