加入收藏 | 设为首页 | 会员中心 | 我要投稿 晋中站长网 (https://www.0354zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

mysql数据库建立_Mysql 数据库创建基本步骤

发布时间:2022-10-31 14:02:19 所属栏目:MySql教程 来源:互联网
导读: 1.创建数据库
create database school;
2.使用数据库
Use school;
3.创建用户
create user jame@localhost identified by 'jame';
4.授权用户(注意这里是用了*哦,自己将school也替

1.创建数据库

create database school;

2.使用数据库

Use school;

3.创建用户

create user jame@localhost identified by 'jame';

4.授权用户(注意这里是用了*哦,自己将school也替换成*号)

grant select,update,insert,create on school.* to jame@localhost identified by 'j ame';

5.取消授权(现在明白为啥直接敲privilege 没用了吧?)

revoke select,update,insert,create on school.* from jame@localhost;

6.创建表

create table students(s_name varchar(10) not null,age int(3),sex char(1),heig ht int,s_no varchar(20) not null,primary key(s_no));

7.修改表名

alter table students rename to student;

8.修改列

alter table students change s_name name varchar(20) not null;

9.增加列

alter table student add class varchar(20);

10.删除列

alter table student drop column class;

11.删除表

drop table student;

12.删除用户

drop user jame;

13.删除数据库

drop database school;

查看数据库的表结构方法 desc students; 或者 describe students; 另:mysql用户进入控制台后无法切换用户,只能先退出终端MySQL 创建数据库,再重新连接。

(编辑:晋中站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!