标签:增删改查 cacti grants commit 备份数据库 .sql 用户 ati show
数据库
1查询
Select * From table
select host,user,password from mysql.user where user=‘ybb‘ and host=‘%‘; 查询用户
select user,host,password from mysql.user;(查看用户,IP,密码对应表)
select user,host,db from mysql.db;(查看用户,IP,数据库对应表)
select distinct user from mysql.user;(查看所有用户)
2删除
truncate + 表名 删数据柳表结构
delete from t_learner
3事务运行命令
/opt/server/mysql/bin/mysql
begin
commit
4修改root密码
方法1
mysql -hlocalhost -uroot -p
mysql>update mysql.user set password=password(‘新密码‘) where User="root"andHost="localhost";
方法2:用mysqladmin
格式:mysqladmin -u用户名 -p旧密码 password 新密码
例子:mysqladmin -uroot -p123456 password 123
5赋权
grant select,insert,update,delete,create on wlc.* to wlc@localhost identified by ‘wlc123‘; 赋权增删改查
grant all privileges on wlcpay.* to wlcpay@"%" identified by ‘wlcpay123‘; 赋权所有权限
flush privileges; 刷新权限列表
show grants for authuser; 查看用户权限
6添加索引
1).添加PRIMARY KEY(主键索引)
mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )
2).添加UNIQUE(唯一索引)
mysql>ALTER TABLE `table_name` ADD UNIQUE (
`column`
)
3)添加INDEX(普通索引)
CREATE INDEX idx_tlearner_learnerUserID ON vocedudb.t_learner(LearnerUserID);
mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column` )
4).添加FULLTEXT(全文索引)
mysql>ALTER TABLE `table_name` ADD FULLTEXT ( `column`)
5).添加多列索引
mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )
7 查看MYSQL数据库中所有用户
mysql> SELECT DISTINCT CONCAT(‘User: ‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user;
查看数据库中具体某个用户的权限
mysql> show grants for ‘cactiuser‘@‘%‘;
备份数据库里表 mysqldump -hip oil_statistics wl_daily_email -uwanglibao_yunwei -p > wl_daily_email2017.11.9
恢复
mysql -hhost -uroot -p user<user_back.sql
8 查看指定数据库的表的大小,
mysql> SELECT CONCAT(ROUND(SUM(DATA_LENGTH/1024/1024),2),‘MB‘) AS DATA FROM information_schema.TABLES WHERE table_schema=‘mysql‘ and table_name=‘user‘;
标签:增删改查 cacti grants commit 备份数据库 .sql 用户 ati show
原文地址:https://www.cnblogs.com/donghui521/p/9718136.html