After logging into the MySQL service, we can use the
create
Command to create the database, the syntax is as follows:
CREATE DATABASE 数据库名;
The following command simply demonstrates the process of creating a database, named RUNOOB:
[root@host]# mysql -u root -p
Enter password:****** # 登录后进入终端
mysql> create DATABASE RUNOOB;
Create a database using mysqladmin ¶
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.
The following command simply demonstrates the process of creating a database, named RUNOOB:
[root@host]# mysqladmin -u root -p create RUNOOB
Enter password:******
The MySQL database RUNOOB is created after the above command is executed successfully. PHP usage This function takes two arguments and returns on successful execution. Create a database using a PHP script ¶
mysqli_query
Function to create or delete an MySQL database.
TRUE
Otherwise, return
FALSE
.
Grammar ¶
mysqli_query(connection,query,resultmode);
Parameters. | Description |
|---|---|
connection | Necessary. Specifies the MySQL connection to be used. |
query | Required, specify the query string. |
resultmode | Optional. A constant. It can be any of the following values:
Example ¶The following example demonstrates using PHP to create a database: Create a database <?php$dbhost='localhost';//mysql服务器主机地址$dbuser='root';//mysql用户名$dbpass='123456';//mysql用户名密码$conn=mysqli_connect($dbhost,$dbuser,$dbpass);if(!$conn){die('连接错误:'.mysqli_error($conn));}echo'连接成功<br
/>';$sql='CREATE DATABASE
RUNOOB';$retval=mysqli_query($conn,$sql);if(!$retval){die('创建数据库失败:'.mysqli_error($conn));}echo"数据库
RUNOOB 创建成功\\n";mysqli_close($conn);?>
When the execution is successful, the following result is returned:
If the database already exists, the following result is returned after execution:
Principles, Technologies, and Methods of Geographic Information Systems 102 In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.
|

