How to create a database

angryTom
Release: 2019-08-12 16:13:03
Original
70872 people have browsed it

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//m.sbmmt.com/mysql-tutorials-362227.html

1. Log in to the database

Code:

mysql -u root -p
Copy after login

Enter password

How to create a database

2. Create database

Code:

create database test;
Copy after login

How to create a database

3. Use the database just created

Code:

use test;
Copy after login

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));
Copy after login

How to create a database

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

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

How to create a database

6. Query data

Code:

select * from user;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!