当前位置:网站首页>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 to register a free website domain name
- August 20, 2021: brick making. There is a binary grid of m x n, where 1 table
- Oceanus practice - use of the Nepal graph connector in the graph database
- How to register a first level domain name what is a first level domain name
- Use of golang testing framework test
- What is the function of DNS domain name server? What is called top-level domain name
- MySQL cases MySQL find out who holds the row lock (RC)
- 014_ TimePicker time selector
- Shuttle global levitation button
- Build personal leanote cloud notebook with Tencent cloud lightweight application server
猜你喜欢

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

CTF learning notes 18:iwesec file upload vulnerability-03-content-type filtering bypass
Easy to understand JDBC tutorial - absolutely suitable for zero Foundation
What cloud native knowledge should programmers master?

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

011_ Cascader cascade selector

How does win10 turn off f1~f12 shortcut keys?

014_ TimePicker time selector

Leetcode question brushing (question 3) - the longest substring without repeated characters
![[leetcode daily question] push domino](/img/81/1c31e97d9a245816514bcf47c92107.jpg)
[leetcode daily question] push domino
随机推荐
Leetcode (question 1) - sum of two numbers
Talk about team management: how to build your own management system!
Spirit breath development log (12)
What is a domain name address? What is the reason for using a domain name address?
Shutter - how to copy certain elements from a map to a new map in dart/shutter?
Shuttle global levitation button
Some excellent plug-ins on Amway vscode
PTA 1041 seat number (15 points)
The principle of defer keyword in go
[Tencent cloud] new enterprise users go to the cloud & the latest discount 2022!
[jest] summary of the use of automated test jest
What domain name is com? How to register a domain name
How to set easycvr recording plan batch and single channel settings?
Tencent cloud installs Kedao cloud - build an exclusive private cloud disk
PHP uasort() function
PHP key() function
[leetcode daily question] push domino
What is domain name filing? What is the role of domain name filing?
Tencent cloud + community video [technology star push official] FAQ
MySQL cases MySQL find out who holds the row lock (RC)