How to create a database in mysql?

藏色散人
Release: 2019-05-05 16:18:49
Original
6922 people have browsed it

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 数据库名;
Copy after login

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;
Copy after login

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:******
Copy after login

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!