mysql常用命令

DB拷贝
/home/cec/mysql/MySQLOrig/bin/mysqldump hshard-1 -uroot -proot --add-drop-table | mysql -h172.16.34.12 hshard-0 -ucec -pcec
给存在用户赋权限
grant all privileges on cec_ly_3.* to cec@'%';
FLUSH PRIVILEGES;
给不存在用户赋权限
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'repl';
修改表语句
alter table  CEC_TicketOrder ADD primary key(`id`);
alter table  CEC_TicketOrder add unqiue `IDX_TicketOrder_code`(`code`) USING BTREE;
alter table  CEC_TicketOrder add index `IDX_TicketOrder_createTime`(`createTime`)  USING BTREE;
alter table  CEC_TicketOrder add unqiue `IDX_TicketOrder_channelOrderCode`(`channelOrderCode`) USING BTREE;
 
linux执行Mysql命令
mysql -e "use cec; select count(1) from cec.abcd";
 
mysql获取所有表的查询的SQL语句

 

SELECT CONCAT('mysql -e "', 'use cec; ','select concat(\'', TABLE_NAME, '\',','\'_\'', ',count(1)', ') from ', TABLE_NAME, '" >> /home/cec/tmp.log') from      where TABLE_SCHEMA = 'cec_for_xf';

你可能感兴趣的:(mysql常用命令)