mysql的常用操作

通用篇

1.使用mysqldump来操作

http://www.jb51.net/article/28855.htm

2.mysql批量删除表格

  2.1.生成删除表格需要执行的命令

  select concat('drop table ', table_name, ';') from information_schema.`TABLES` where TABLE_NAME like 'macc_sta_online_history_%';

  2.2.执行此语句产生的语句

3.mysql -e

  3.1 mysql -uroot -proot test --execute="select * from test"

4.mysql --prompt=name

  4.1 windows下—mysql -uroot -proot --prompt="<\u@\h:\d|mysql>"

  4.2 linux下—mysql -uroot -proot --prompt="<\\u@\\h:\\d|mysql>"

  结果=><macc@localhost:test|mysql>

  可在my.cnf或mysql.ini中配置

  windows => C://Windows//my.cnf

  Linux => /etc/my.cnf

5.mysql --tee=name 记录下所有的命令和结果到固定文件夹中

  5.1 mysql --tee="c://1.txt"

6.查看mysql服务器版本信息 status

7.授权操作

  7.1grant select on *.* to 'test1'@'localhost' identified by 'root'; 红字的部分非常重要,一定要加上

查询用户当前拥有哪些权限

show grants for 'cactiuser'@'%';

8.备份mydump

mysqldump -uroot -proot -T/C:/tmp/ macc test_outfile --fields-enclosed-by=\" --fields-terminated-by=,

这个命令中,-T选项实际上是用了select into outfile这个命令,而这个命令需要file权限。 普通的mysqldump不一定需要此权限。

posted @ 2015-08-25 16:11  無限大  阅读(251)  评论(0编辑  收藏  举报