时间:2021-07-01 10:21:17 帮助过:2人阅读
mysql > set password=password=(‘修改的密码‘); //修改密码
mysql > show databases; //显示所有数据库
mysql > use mysql; //使用mysql数据库
mysql > show tables; //查看该数据库的表
mysql > update user set authentication_string=password(‘你的密码‘) where user=‘root‘ //直接在user表里修改root的密码为编码之后设置的密码
mysql > flush privileges; //刷新
mysql > create database test01 default character set utf8 collate utf8_general_ci; //建库并设置编码和排序方式
mysql > drop database test01; //删库
mysql > CREATE TABLE `teacher` //创建一个teacher表
-> (
-> `tid` int(8) UNSIGNED NOT NULL COMMENT ‘老师号‘ , //该字段为tid,int类型,长度8个字节,无符号,不允许空值,备注老师号
-> `Tname` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT ‘老师名字‘ , //该字段为Tname,varchar类型,长度32个字节,字符集为utf8,排序方式为utf8_general_ci,不允许为空值,备注老师名字
-> PRIMARY KEY (`tid`) //tid为关键字
-> )
-> ENGINE=InnoDB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC; //ENGINE=InnoDB使用默认存储引擎,URF8字符集,utf8_general_ci排序方式
mysql > describe teacher; //查看表结构
mysql > drop table teacher; //删除表
mysql > insert into teacher values(1,‘wendy‘); //在表里插入数据
mysql > insert into teacher set tid=1,tname=‘wendy‘; //在表里插入数据(推荐使用这种方式)
mysql > insert into test01.teacher select *from test_project.teacher; //从别的表复制数据过来,记住表结果必须一致
mysql > delete from teacher where tid=1 //删除数据
mysql > update teacher set tname=‘wendy’ where tid=2 //修改数据
mysql > exit //退出mysql
MYSQL之——基础SQL
标签:into 符号 arch data 创建 database sig l数据库 create