Home > Database > Mysql Tutorial > How to use MySQL database, how to use MySQL?

How to use MySQL database, how to use MySQL?

黄舟
Release: 2017-08-01 13:30:40
Original
3245 people have browsed it

Sometimes when we are doing development, we need to use the mysql database. How to use it? The editor below will share how to use mysql

1. The first step is to install it on the computer After setting up the myql database, open the mysql command line, enter the password, and press Enter, as shown below:

How to use MySQL database, how to use MySQL?

## 2. In the second step, enter "create database day1;" and press Enter to create a database for day1. Pay attention to the semicolon. Query OK shows that it has been created

How to use MySQL database, how to use MySQL?

3. In the third step, enter "use day1;", enter the day1 database, and start the table creation operation

How to use MySQL database, how to use MySQL?

4. In the fourth step, the editor creates a test table here:

create table test(
id varchar(20)  primary key ,
name varchar(30),
password varchar(30)
);
Copy after login

Press the Enter key to see that it has been created successfully

How to use MySQL database, how to use MySQL?

Add, delete, modify and query the table

1. Enter

“insert into test(id,name,password) values('001','lisi','123456');”
Copy after login
# in the first step

##, press Enter, you can see that a row of data has been inserted into the test table, as shown below:


How to use MySQL database, how to use MySQL?

2. In the second step, enter "select * from test;" to view the data of the test table we created

How to use MySQL database, how to use MySQL?##3. In the third step, enter

“update test set password='xxxx' where id='001';”
Copy after login
and change the password with ID 001 to xxxx. Press the Enter key to see that the change has been successful


How to use MySQL database, how to use MySQL?4. In the fourth step, we enter "select * from test;" to check the table and you can see The contents of the table have been changed

How to use MySQL database, how to use MySQL?

##Delete the database and table

1. In the first step, enter "drop table test;" to delete the test table, as shown in the following figure:

How to use MySQL database, how to use MySQL?2. In the second step, enter "drop database day1;" to delete the day1 database. Pay attention to the English semicolon, as shown in the following figure:

##

The above is the detailed content of How to use MySQL database, how to use MySQL?. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template