1.登陆命令:mysql -u root -p;
2.查看版本命令:mysql -V;
3.创建数据库:create database db1;
4.使用数据库:use db1;
5.查询数据库的表:show tables;
6.创建表:create table shanname(id int(10) primary key,name varchar(20) not null,class varchar(5) not null);
7.新增表一列:alter table shanname add(teacher char(5) not null);
修改id列的属性: alter table shanname change id id int(10) auto_increment;
8.查看表结构:
desc tablename;/ show create table tablename;
9.新增数据:
insert into shanname values(null,'xxx','xxx','xxx');/insert into shanname (name,class,teacher) values ("xxx","xxx","xxx");
10.查询表达 所有数据:select * from shanname;
11.更改数据:update shanname set class='yinianji' where class='一年级';##把一年级更改为“yinianji”
12.查看当前编码:show variables like '%char%';
13.修改mysql编码为utf-8:
set character_set_client = utf8;
set character_set_server = utf8;
set character_set_connection = utf8;
set character_set_database = utf8;
set character_set_results = utf8;
set collation_connection = utf8_general_ci;
set collation_database = utf8_general_ci;
set collation_server = utf8_general_ci;