Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL commands to create a database

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "MySQL commands to create a database", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "MySQL commands to create a database"!

MySQL to create a database using mysqladmin to create a database

With normal users, you may need specific permissions to create or delete MySQL databases.

So we use the root user to log in, and the root user has the highest privileges, so we can use the mysql mysqladmin command to create the database.

Example

The following command simply demonstrates the process of creating a database, named chenweiliang:

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

The MySQL database chenweiliang is created after the above command is executed successfully.

Create a database using a PHP script

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

This function takes two arguments and returns TRUE on successful execution, or FALSE otherwise.

Syntax mysqli_query (connection,query,resultmode); parameter description connection is required. Specifies the MySQL connection to be used. Query is required, specifying the query string. Resultmode is optional. A constant. It can be any of the following values:

MYSQLI_USE_RESULT (use this if you need to retrieve a large amount of data)

MYSQLI_STORE_RESULT (default)

Example

The following example demonstrates using PHP to create a database:

Create a database

When the execution is successful, the following result is returned:

Connected successfully

Database chenweiliang created successfully

At this point, I believe that you have a deeper understanding of the "MySQL database creation command", might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report