数据库:

1、创建一个数据库:

create database dgf;

create database if not exists dgf;

2、查看创建的数据库是否成功:

show databases;

3、删除数据库:

drop database dgf;

数据表:

CREATE TABLE students(id TINYINT,Name CHAR(20) NOT NULL,Age TINYINT,Gender CHAR(1) NOT NULL);

查看库中的表: show tables from testdb;

查看表结构:desc  students;

删除表:drop table students;

修改表; alter table students add course varchar(100);

修改字段用change,修改字段的属性用modify:

例如把course改成Course 并且放在name 的下边

alter table students change course Course varchar(100) after name;

往表中插入数据:

 insert into students(Name,Gender) value ('zhangsan','M'),('xiaoming','F');

修改表中的数据update:

update students set id=1 where name='zhangsan';

删除表中的数据;

delete from students where name='zhangsan';

创建用户:

create user 'dgf'@'%' identified by '123456';

删除用户:

drop user 'dgf'@'%';

给用户修改密码:

mysql> set password for 'root'@'localhost'=password('123456');

#mysqladmin -uroot -p password 'password'