Create a database using Mysqladmin
With a normal user, you may need specific permissions to create or delete a MySQL database.
So here we are using the root user login, the root user has the highest privileges, you can use the MySQL mysqladmin command to create a database.
Instance
The following command simply demonstrates the process of creating a database with the data name tutorials:
[[email protected]] - - Create tutorialsenter Password: ******
After successful execution of the above command, MySQL database tutorials will be created.
creating a database using PHP scripts
PHP uses the Mysql_query function to create or delete MySQL databases.
The function has two parameters, returns TRUE on successful execution, or FALSE.
Grammar
mysql_query (SQL, connection);
| Parameters |
Description |
| Sql |
Necessary. Specifies the SQL query to send. Note: The query string should not end with a semicolon. |
| Connection |
Optional. Specifies the SQL connection identifier. If not specified, the previous open connection is used. |
Instance
The following example demonstrates the use of PHP to create a database:
MySQLdatabase</title>PHP$dbhost= ' localhost:3036 ';$dbuser= ' Root ';$dbpass= ' Rootpassword ';$conn=mysql_connect($dbhost,$dbuser,$dbpass);if(!$conn ){ die(' Could not connect: '.Mysql_error());}Echo' Connected successfully<br/> ';$sql= ' CREATE DATABASE tutorials ';$retval=mysql_query($sql,$conn );if(!$retval ){ die(' Could not create database: '.Mysql_error());}Echo"Database Tutorials created successfully\n";Mysql_close($conn);?></body>Original address: http://www.manongjc.com/mysql/mysql_create_database.html
Related reading:
- MySQL Delete Database
- MySQL Select Database
- MySQL data type
- MySQL Create data table
- MySQL Delete Data Sheet
- MySQL Inserting data
- MySQL query data
MySQL creates a database using PHP