mysql basic operations
- 2020-05-13 03:39:08
- OfStack
Under window, start and stop the mysql service
Start the mysql database
net start mysql
Stop the mysql database
net stop mysql
Restart the mysql database
net restart mysql
Command line format, mysql basic command use
1. Cancellation of command
\c
2. Exit the mysql window
exit; Or quit; Or ctrl + c
3. Check the database version number
select version();
4. Display the existing database
show databases;
5. Select test database
use test;
6. View the selected database
select database();
7, set the database Chinese code
set names utf8;
8. Create an test database
create database test
9. Create a table mtest
create table mtest(
id tinyint(2) unsigned not null auto_increment,
name varchar(20),
sex char(1),
email varchar(50),
birth datetime,
primary key (id)
);
10. Insert 1 data into mtest table
insert into mtest(`name`,`sex`,`email`,`birth`) values ('zhangsan','1','zhangsan@163.com',now());
11. Query the mtest table for sheet 3 of name
select * from mtest where name='zhangsan';
12. Output in descending order according to id
select * from mtest order by id desc;
13. Display items 11 to 20
select * from mtest id limit 10,10;
Start the mysql database
net start mysql
Stop the mysql database
net stop mysql
Restart the mysql database
net restart mysql
Command line format, mysql basic command use
1. Cancellation of command
\c
2. Exit the mysql window
exit; Or quit; Or ctrl + c
3. Check the database version number
select version();
4. Display the existing database
show databases;
5. Select test database
use test;
6. View the selected database
select database();
7, set the database Chinese code
set names utf8;
8. Create an test database
create database test
9. Create a table mtest
create table mtest(
id tinyint(2) unsigned not null auto_increment,
name varchar(20),
sex char(1),
email varchar(50),
birth datetime,
primary key (id)
);
10. Insert 1 data into mtest table
insert into mtest(`name`,`sex`,`email`,`birth`) values ('zhangsan','1','zhangsan@163.com',now());
11. Query the mtest table for sheet 3 of name
select * from mtest where name='zhangsan';
12. Output in descending order according to id
select * from mtest order by id desc;
13. Display items 11 to 20
select * from mtest id limit 10,10;