天天看点

MySQL命令行基本命令操作

进入命令模式后,

显示所有数据库

show databases;
      

 选定某个数据库

use 数据库名;
      

 创建数据库

create database  数据库名;
      

 删除数据库

drop table 数据库名;
      

 显示数据库的所有表

show tables;
      

 创建表

create table 表名;
      

 删除表

drop table 表名;
      

 清空表

delete table 表名;
      

 查看表内容

select * from 表名;
      

 查看某个表的具体表结构

describe 表名;
      

 修改表内容的值

update 表名 set 参数名=要改成的值 where 参数名=某个值;
      

 查看存储过程

show procedure status;
      

查看存储过程的具体内容

show create procedure 存储过程名
      

创建用户

grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"
      

用户已存在赋予权限

grant select,insert,update,delete  on 数据库.* to 用户名@登录主机 identified by "密码"
      

当然,权限有14种权限

select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process
      

不设置用户密码的话

grant select,insert,update,delete  on 数据库.* to 用户名@登录主机 identified by ""
      

删除用户

drop user 用户名;
      

 查询所有用户

select user from mysql.user;
      

查看当前用户

select user();
      

查询时间

select now();
      

查询数据库版本

select version;
      
select database();