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.
2017-11-11, 663👍, 0💬
Popular Posts:
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...
How to download and install the scaled-down database AdventureWorksLT in SQL Server? If you want to ...
How To Define an External Table in a Text File in Oracle? You can use the CREATE TABLE statement to ...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want t...