--root 登陆
mysql -u root;
--创建数据库
create database mydb;
--查看数据库
show databases;
--使用数据库
use mydb;
--查看表
show tables;
--查看表属性
desc study;
--创建表:
create table study(
id int(11) not null auto_increment primary key comment 'the id',
username varchar(50) default 'my student' comment 'student name',
create_date date,
createdate datetime
);
--添加数据
insert into study (username,create_date,createdate) values ('jack',now(),now());
--创建用户
craete user 'lcd'@'%' identified by '123456';
--授权
grant all on mydb.* to 'lcd';
--设置密码
set password for 'lcd'@'%' = password('012345');
--撤销权限
revoke all on lesson.* from 'lcd';
--删除用户
delete from user where user='lcd';
drop user 'lcd'@'%';(推荐)
--刷新权限
flush privileges
--增加新用户后,需以下操作,方可登陆
delete from mysql.user where user='';
flush privileges;
service mysql restart;
mysql -u root;
--创建数据库
create database mydb;
--查看数据库
show databases;
--使用数据库
use mydb;
--查看表
show tables;
--查看表属性
desc study;
--创建表:
create table study(
id int(11) not null auto_increment primary key comment 'the id',
username varchar(50) default 'my student' comment 'student name',
create_date date,
createdate datetime
);
--添加数据
insert into study (username,create_date,createdate) values ('jack',now(),now());
--创建用户
craete user 'lcd'@'%' identified by '123456';
--授权
grant all on mydb.* to 'lcd';
--设置密码
set password for 'lcd'@'%' = password('012345');
--撤销权限
revoke all on lesson.* from 'lcd';
--删除用户
delete from user where user='lcd';
drop user 'lcd'@'%';(推荐)
--刷新权限
flush privileges
--增加新用户后,需以下操作,方可登陆
delete from mysql.user where user='';
flush privileges;
service mysql restart;