mysql

mysql常用命令

2019-06-28  本文已影响0人  一条小团团ovo的就很棒

1.进入:mysql -u 用户名 -p 回车输入密码

2.退出:exit

3.展示数据库:mysql>show databases;

4.使用某数据库:mysql>use mysql;

5.修改密码: mysql>set password for root@localhost = password('12345');

6.修改用户名:mysql>update user set user="zzc" where user="root";

7.判断某数据库存在,再删除:mysql>drop database if exists zzc;

8.直接删除某数据库:mysql>drop database zzc;

9.展示数据表:mysql>show tables;

10.判断某数据表存在,再删除:mysql>drop table if exists users;

11.直接删除表:mysql>drop table users;

12.创建表:mysql>

create table student {
 id int auto_increment primary key, //将id设置为主键 ,auto_increment表示自增
 name varchar(50),
 sex varchar(20),
 date varchar(50),
 content varchar(100)  
} default charset =utf8;

13.插入数据:mysql>insert into student values(null,"zzc","男","1996-04-06","......");

14.修改数据:mysql>update student set date="1996-05-06" where name="zzc";

15.删除数据:mysql>delete from student where name="zzc";

16.查询所有数据:mysql>select * from student;

上一篇下一篇

猜你喜欢

热点阅读