Home >Database >Mysql Tutorial >How to use MySQL database, how to use MySQL?
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:
## 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
3. In the third step, enter "use day1;", enter the day1 database, and start the table creation operation
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) );
Press the Enter key to see that it has been created successfully
Add, delete, modify and query the table
1. Enter
“insert into test(id,name,password) values('001','lisi','123456');”# in the first step ##, press Enter, you can see that a row of data has been inserted into the test table, as shown below:
2. In the second step, enter "select * from test;" to view the data of the test table we created
##3. In the third step, enter
“update test set password='xxxx' where id='001';”and change the password with ID 001 to xxxx. Press the Enter key to see that the change has been successful
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
##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:
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!