sql常用命令

mysql -utest -p -h 192.168.100.10      oracle的用户只有sysdba sysoper可以启动停止数据库
/etc/my.cnf   skip-grant-tables
log-bin=mysql-bin  开启bin-log日志
set password=password('123qwe');
set password for test@'%'=password('123qwe');

update mysql.user set password=password('123qwe') where use='root';
create table people(id int(10),name char(32),sex char(6))
describe people
insert into people (id,name,sex) values (1,'Rain','man'),(2,'Alex','w')
insert into a1 (id,name) select id,name from a2  表间数据复制
delete from a2 where id=3
delete from a2 where age between 20 and 30; a2中删除年纪在20到30的记录
update a2 set age=17 where id=2; 修改表数据,将年龄改为17
alter table a2 rename table2  改表名
alter table a1 modify name char(30)  修改表的字段的属性
alter table a1 change name usernam(1) after id;在id字段后添加sex字段
alter table a1 drop time;删除time字段
grant all on . to test@'%' identified by '123qwe';
grant select on redis.* to test@'%' identified by '123qwe'
show grants for test@'%'
添加权限使用grant,取消权限使用revoke
mysql -uroot -p aa>~/1.sql 备份aa数据库
mysql -uroot -p --databases aa test>2.sql 同时备份aa和test数据库
mysql -uroot -p aa<1.sql 将备份的数据导入数据库
mysqlhotcopy --flushlog -u='root' -p='456' --regexp=^a /mnt
备份以a开头的数据库到/mnt下
还原的时候直接将备份文件copy -a 到/var/lib/mysql/下
mysqlbinlog mysql-bin.00001 查看sql的bin-log日志
mysqlbinlog --start-position 264 --stop-position 341 mysql-bin.00001|mysql

start slave; start master;show slave status\G;

查看原文:http://www.chenqmc.com/?p=451
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值