mysql授权以及状态查询
create database odi; -- 创建odi数据库
grant all privileges on *.* to odi@'%' identified by 'odipasswd'; -- 远程授权;
flush privileges; -- 刷新授权表
delete from user where user=odi; -- 删除该用户授权
create database allen;
grant all privileges on test.* to odi@'%' identified by 'odipasswd'; -- 远程授权
grant all privileges on test to odi@'%' identified by 'odipasswd'; -- 远程授权
grant all privileges on phplampdb.* to phplamp@localhost identified by '1234';
-- grant 权限 on 数据库名.表名 用户@登录主机 identified by 用户密码;
-- grant 权限 on 数据库名.表名 用户@登录主机 identified by 用户密码;
-- select host,user,password from user;
-- update user set host = ’%’ where user = ’fang’;
create database ccc;
grant all privileges on ccc.* to ccc@'%' identified by 'cccpasswd'; -- 远程授权;
flush privileges; -- 刷新授权表
-- 新建用户
insert into mysql.user(host,user,password) values(%,testdb,password(testpasswd));
-- 创建新数据库
create database testdb;
-- 授权test用户拥有testdb数据库的所有权限(某个数据库的所有权限)
grant all privileges on testdb.* to test@localhost identified by 'testpasswd';
-- 授权test用户拥有所有数据库的某些权限
grant select,delete,update,create,drop on *.* to test@% identified by 1234;
-- 删除用户
delete from user where user='test' and host='localhost';
flush privileges;
drop database testdb; //删除用户的数据库
-- 删除账户及权限:
drop user 用户名@'%';
drop user 用户名@ localhost;
-- 修改某一个用户的密码
update mysql.user set password=password('新密码') where user=test and host=localhost;
flush privileges;
-- 列出所有数据库
show databases;
-- 切换数据库
use database_name;
-- 列出所有表
show tables;
-- 显示表结构
describe tables_name;
-- 删除数据库
drop database database_name;
-- 删除数据表
drop table tables_name;
,
