当前位置:网站首页>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);
?>
边栏推荐
- Youtech sharing | the application of Tencent Youtu multimodal graphic content identification and positioning in content security
- Shuttle global levitation button
- [Tencent cloud 818] cloud product time limited spike & lightweight application server lighthouse & how to get the most affordable?
- What is a domain name address? What is the reason for using a domain name address?
- [competition experience sharing] a problem-solving summary of the whole DFS (internal track)
- PHP sizeof() function
- [competition experience sharing] [Tencent internal track rank6] goose Rose Square half hand (TAS) experience
- CMU cs15-445 lecture01 relationship model course notes
- Is there a free ECS? What should I pay attention to when I rent a server
- [Tencent cloud] buy a cloud server, participate in a gift lottery, and give you an iPad worth 8000 yuan, Bose earphones, and a thousand yuan JD card!
猜你喜欢

How does win10 turn off f1~f12 shortcut keys?
What cloud native knowledge should programmers master?

014_ TimePicker time selector

011_ Cascader cascade selector
![[leetcode daily question] push domino](/img/81/1c31e97d9a245816514bcf47c92107.jpg)
[leetcode daily question] push domino

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

Intensive learning and application of "glory of the king" to complete the application of 7 real worlds other than human players

Answer questions! This article explains the automated testing framework in software testing from beginning to end

CTF learning notes 18:iwesec file upload vulnerability-03-content-type filtering bypass

How should we learn cloud native in 2022?
随机推荐
Bert series Roberta Albert erine detailed explanation and use learning notes
Is it useful to build an industrial knowledge map platform?
SUSE system cannot install cosfs solution
Elfk service setup
Flutter common development problems
What is the difference between a traditional data center and a cloud computing data center?
Three methods of local storage
CMU cs15-445 lecture01 relationship model course notes
The easyplayer player displays compileerror:webassembly Reason for instance() and its solution
Cos+cdn realizes the distribution of game client version files in a faster, better and cheaper manner
What is a domain name address? What is the reason for using a domain name address?
2021-08-27: the normal odometer will display natural numbers in turn to indicate mileage, Kyrgyzstan
014_ TimePicker time selector
The most complete regular expression summary in the whole network, so that you can get twice the result with half the effort. Collect it quickly
Error 0xc0000013, 0xc000007b, etc. due to the conflict between the CD-ROM drive letter and the drive letter in the business program path
Shuttle global levitation button
[latest offer] 2-core 4G server is limited to 188 yuan, and it is in the process of being snapped up
Fluent version control FVM
What is primary domain name? What are the divisions of domain names
What domain names do not need to be filed? Is there any process for domain name registration