Home >Database >Mysql Tutorial >How to create a database in mysql?

How to create a database in mysql?

藏色散人
藏色散人Original
2019-04-29 14:23:327049browse

How to create a database in mysql?

How to create a database in mysql?

Mysql has three ways to create a database:

1. Use the create command to create a database

We can use the create command to create after logging in to the MySQL service Database, the syntax is as follows:

CREATE DATABASE 数据库名;

The following command simply demonstrates the process of creating a database. The data name is DEMO:

[root@host]# mysql -u root -p   
Enter password:******  # 登录后进入终端mysql> create DATABASE DEMO;

2. Use mysqladmin to create the database

Using a normal user, you may need specific permissions to create or delete MySQL databases.

So we use the root user to log in. The root user has the highest authority and can use the mysql mysqladmin command to create the database.

The following command simply demonstrates the process of creating a database. The data name is DEMO:

[root@host]# mysqladmin -u root -p create DEMO Enter password:******

After the above command is successfully executed, the MySQL database DEMO will be created.

3. Use PHP script to create a database

PHP uses the mysqli_query function to create or delete a MySQL database.

This function has two parameters and returns TRUE when executed successfully, otherwise it returns FALSE.

Grammar

mysqli_query(connection,query,resultmode);

Related recommendations: "mysql tutorial"

The above is the detailed content of How to create a database in mysql?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn