Home >Database >Mysql Tutorial >How to create a database

How to create a database

angryTom
angryTomOriginal
2019-08-03 13:18:0070996browse

How to create a database

Data is the basic operation of learning programming. Here is an introduction to how to create a database with mysql.

Recommended tutorial: MySQL introductory video tutorial

Prerequisite: The computer has the mysql service installed . If you don’t know how to install the mysql service, you can refer to https://www.php.cn/mysql-tutorials-362227.html

1. Log in to the database

Code:

mysql -u root -p

Enter password

How to create a database

2. Create database

Code:

create database test;

How to create a database

3. Use the database just created

Code:

use test;

How to create a database

4. Create a table

Code:

create table user(id int not null,username varchar(100) not null,password varchar(100) not null,primary key(id));

How to create a database

##5. Add a piece of data to the table

insert into user(id,username,password) values(1,'zhang','123');

How to create a database

6. Query data

Code:

select * from user;

How to create a database

The above is the detailed content of How to create a database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to start mysqlNext article:How to start mysql