当前位置:网站首页>Creating a database using mysqladmin
Creating a database using mysqladmin
2022-06-24 05:21:00 【User 4988376】
We can log in MySQL After service , Use create Command create database , The grammar is as follows :
CREATE DATABASE Database name ;
The following command simply demonstrates the process of creating a database , The data name is RUNOOB:
[[email protected]]# mysql -u root -p Enter password:****** # Enter the terminal after logging in mysql> create DATABASE RUNOOB;
Use mysqladmin Create database
Use ordinary users , You may need specific permissions to create or delete MySQL database .
So we use root The user login ,root The user has the highest authority , have access to mysql mysqladmin Command to create a database .
The following command simply demonstrates the process of creating a database , The data name is RUNOOB:
[[email protected]]# mysqladmin -u root -p create RUNOOB Enter password:******
After the above command is executed successfully, it will create MySQL database RUNOOB.
Use PHP Script Create database
PHP Use mysqli_query Function to create or delete MySQL database .
This function takes two arguments , Returns... On successful execution TRUE, Otherwise return to FALSE.
grammar
mysqli_query(connection,query,resultmode);
Parameters | describe |
|---|---|
connection | It's necessary . Stipulate what to use MySQL Connect . |
query | It's necessary , Specify the query string . |
resultmode | Optional . A constant . It can be any of the following values :MYSQLI_USE_RESULT( If you need to retrieve a lot of data , Please use this )MYSQLI_STORE_RESULT( Default ) |
- MYSQLI_USE_RESULT( If you need to retrieve a lot of data , Please use this )
- MYSQLI_STORE_RESULT( Default )
example
The following example demonstrates the use of PHP To create a database :
Create database
<?php
$dbhost = 'localhost'; // mysql Server host address
$dbuser = 'root'; // mysql user name
$dbpass = '123456'; // mysql User name, password
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die(' Connection error : ' . mysqli_error($conn));
}
echo ' Successful connection <br />';
$sql = 'CREATE DATABASE RUNOOB';
$retval = mysqli_query($conn,$sql );
if(! $retval )
{
die(' Failed to create database : ' . mysqli_error($conn));
}
echo " database RUNOOB Create success \n";
mysqli_close($conn);
?>
边栏推荐
- How the query address of cloud native monitoring data exposes the public network
- 2021-08-27: the normal odometer will display natural numbers in turn to indicate mileage, Kyrgyzstan
- What is the secondary domain name of the website? What is the relationship between the secondary domain name and the primary domain name?
- How to apply for domain name space? Will it be difficult to apply for domain name space?
- What is primary domain name? What are the divisions of domain names
- Wang Wei, senior architect of coding Devops, was selected as the first batch of tutors in Mulan open source community
- Where to register the HK domain name? What should I pay attention to when registering the domain name
- [competition experience sharing] Tencent's internal track - goose Rose Square race notes
- How to register a free website domain name
- PHP uasort() function
猜你喜欢

014_ TimePicker time selector

Leetcode (question 2) - adding two numbers

Hard core observation 553 AI needs to identify almost everyone in the world with hundreds of billions of photos

What are the disadvantages of the free IP address replacement tool?

How should we learn cloud native in 2022?

How does win10 turn off f1~f12 shortcut keys?

Leetcode question brushing (question 3) - the longest substring without repeated characters

011_ Cascader cascade selector

Leetcode (question 1) - sum of two numbers
Learning routes and materials for cloud native O & M engineers
随机推荐
Flutter common development problems
Leetcode question brushing (question 3) - the longest substring without repeated characters
How to apply for free website domain name does the domain name need authentication
2021-08-27: the normal odometer will display natural numbers in turn to indicate mileage, Kyrgyzstan
Analysis of electronic signature system
How to check the Chinese domain name of the website and through what channels?
Build your unique online image
Elfk service setup
Why domain name should be resolved? What is the domain name registration query
[leetcode daily question] push domino
How to expand virtual machine capacity on vSphere client
How to register a free website domain name
System design: Agent & redundancy & replication
What is primary domain name? What are the divisions of domain names
Intensive learning and application of "glory of the king" to complete the application of 7 real worlds other than human players
Edgegallery: MEC open source platform extends 5g capability to the edge
What is a domain name address? What is the reason for using a domain name address?
What cloud native knowledge should programmers master?
PHP ksort() function
What is the secondary domain name of the website? What is the relationship between the secondary domain name and the primary domain name?