mysql utility_MySQL Utility 认知(1)

1: mysqlauditamin

作用:主要用来监察审计日志,但mysql 服务器必须安装 或启用Audit plugin ,不然这个命令使用不了

语法:mysqlauditadmin --server=username:passwd@hostname:port --show-options

2:mysqlauditgrep

作用:看字面意思应该是查找审计日志的你想要的内容,和linux 的grep 用途相似

语法:mysqlauditgrep [options]  audit_log_file ,具体可以通过 mysqlauditgrep --help 查看

3:mysqldncompare

作用:可以用来比对2个数据库之间的差别,生产报告

语法:mysqldbcompare --server1=user:passwd@host1:port --server2=user:passwd@host2:port  db1:db2

例如:

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>mysqldbcompare.exe --server1=root:sbcenter@172.72.15.41 --server2=root:sbcenter@172.72.15.40 gjj:gjj

-a  --changes-for=server2 --show-reverse -f tab

# server1 on 172.72.15.41: ... connected.

# server2 on 172.72.15.40: ... connected.

# Checking databases gjj on server1 and gjj on server2

#

# WARNING: Objects in server1.gjj but not in server2.gjj:

#        TABLE: test1

#

#                                                   Defn    Row     Data

# Type      Object Name                             Diff    Count   Check

# -------------------------------------------------------------------------

# TABLE     gjj_table                               pass    pass    SKIP

#

No primary key found.

# TABLE     gjj_table1                              pass    pass    SKIP

#

No primary key found.

# TABLE     gjj_table2                              pass    pass    SKIP

#

No primary key found.

# TABLE     test                                    pass    FAIL    SKIP

#

# Row counts are not the same among gjj.test and gjj.test.

#

No primary key found.

# Database consistency check failed.

#

# ...done

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>

这里有test 表中的行数不一致,还有server2中没定义test1 表!!

4:mysqlcopy

作用:在不同的mysql服务器之间复制数据库,在同服务器内复制数据库

语法:mysqldbcopy.exe --source=user:pass@host:port:socket  --destination=user:pass@host:port:socket orig_db:new_db

例如:

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>mysqldbcopy.exe --source=root:sbcenter@172.72.15.41 --destinatio

n=root:sbcenter@172.72.15.40 test_new:test_new_des

# Source on 172.72.15.41: ... connected.

# Destination on 172.72.15.40: ... connected.

# WARNING: A partial copy from a server that has GTIDs enabled will by default include the GTIDs of all transactions, ev

en those that changed suppressed parts of the database. If you don't want to generate the GTID statement, use the --skip

-gtid option. To export all databases, use the --all option and do not specify a list of databases.

ERROR: The copy operation contains GTID statements that require the global gtid_executed system variable on the target t

o be empty (no value). The gtid_executed value must be reset by issuing a RESET MASTER command on the target prior to at

tempting the copy operation. Once the global gtid_executed value is cleared, you may retry the copy.

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>mysqldbcopy.exe --source=root:sbcenter@172.72.15.41 --destinatio

n=root:sbcenter@172.72.15.40 test_new:test_new_des

# Source on 172.72.15.41: ... connected.

# Destination on 172.72.15.40: ... connected.

# WARNING: A partial copy from a server that has GTIDs enabled will by default include the GTIDs of all transactions, ev

en those that changed suppressed parts of the database. If you don't want to generate the GTID statement, use the --skip

-gtid option. To export all databases, use the --all option and do not specify a list of databases.

# GTID operation: SET @MYSQLUTILS_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;

# GTID operation: SET @@SESSION.SQL_LOG_BIN = 0;

# GTID operation: SET @@GLOBAL.GTID_PURGED = '42077619-65AC-11E2-9484-000C290429AE:1-8,

E2F3ECB6-613B-11E2-B792-000C29E30F3D:1-135512';

# Copying database test_new renamed as test_new_des

# Copying TABLE test_new.test1

# Copying data for TABLE test_new.test1

# GTID operation: SET @@SESSION.SQL_LOG_BIN = @MYSQLUTILS_TEMP_LOG_BIN;

#...done.

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>

注意:当一开始执行mysqldbcopy的时候,需要在目标库上reset master 清空gtid,方可用此命令

5:mysqldbexport

作用:从数据库中导出元数据和数据,导出的格式可以是:sql,, CSV, TAB, Grid, Vertical

语法:mysqldbexport.exe --server=user:pass@host:port:socket db1, db2, db3

例如:

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>mysqldbexport.exe --server=root:sbcenter@172.72.15.41 -e both test_new > c:\export.ext

其中 -e both  选项是导出数据和元数据

6:mysqldbimport

作用:和mysqldbexport 相反,把元数据和数据导入到数据库中

语法:mysqldbimport.exe --server=user:pass@host:port:socket db1.csv db2.sql db3.grid

例如:

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>mysqldbimport.exe --server=root:sbcenter@172.72.15.40 -i both  c:\export.txt

7:mysqldiff

作用:比较对象的定义,并输出报告,感觉是mysqldbcompare 的细分版

语法:mysqldiff.exe --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1.object1:db2.object1 db3:db4

8:mysqldiskusage

作用:查看数据磁盘的使用情况

语法: mysqldiskusage.exe --server=user:pass@host:port:socket db1 --all

例如:

C:\Program Files\MySQL\MySQL Workbench 5.2 CE\utilities>mysqldiskusage.exe --server=root:sbcenter@172.72.15.41 gjj -all

# Source on 172.72.15.41: ... connected.

NOTICE: Your user account does not have read access to the datadir. Data sizes will be calculated and actual file sizes

may be omitted. Some features may be unavailable.

# Database totals:

+----------+-------------+

| db_name  |      total  |

+----------+-------------+

| gjj      | 11,616,256  |

+----------+-------------+

Total database disk usage = 11,616,256 bytes or 11.00 MB

# Log information.

# The general_log is turned off on the server.

# The slow_query_log is turned off on the server.

# log_error information is not accessible. Check your permissions.

# Binlog information not accessible. Check your permissions.

# Binlog information not accessible. Check your permissions.

# InnoDB data file information is not accessible. Check your permissions.

#...done.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQLUtility - SQLServer 工具箱 软件说明:   在使用SQLServer企业管理器生成SQL脚本时,并没有按照数据库对象的依赖关系对脚本顺序进行排序。这个BUG导致了生成的脚本无法直接执行,开发人员必须手工对其进行排序或者寻找其他替代方案,从而增加了很大的工作量和麻烦。写本工具的初始原因就是为了解决上述问题,既然写好了,就应该和大家共享。在发布之前顺便又添加了清除事务日志的功能,以后有时间、有需要的话,打算添加更多的实用功能。希望这个小工具能给大家带来一些帮助。 运行环境:   由于是使用.NET写的,所以运行前需要安装.NET运行环境,这可能会给您带来一些麻烦(下载和安装运行环境),在此,我对所有受到影响的朋友表示歉意! 本工具支持SQLServer2000+sp2以上版本,希望大家帮忙测试、报告BUG或提出建议,欢迎到我的BLOG来讨论,谢谢! 运行环境下载地址(23M): http://www.microsoft.com/downloads/details.aspx?FamilyId=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en http://www.ustc9703.com/download/get.asp?id=21&type=1&url=1 http://cq.down.chinaz.com/down/NETFramework.exe 如何选择和连接数据库: • 先从下拉框中选择服务器 • 如果使用用户名和密码登录,则填入用户名和密码(不要选择“集成Windows认证”复选框) • 如果使用Windows认证登录,则选中“集成Windows认证”复选框 • 完成上述步骤后,就可以从下拉框中选择数据库了(您也可以点击“重新连接”以刷新数据库信息) • 选择好数据库后,就可以执行以下各项功能 SQL脚本排序: • 使用前请先在SQLServer企业管理器里生成SQL脚本,保存为文件 • 运行本程序,在主界面上选择数据库,点击“脚本排序”按钮进入排序界面 • 在脚本排序界面点“浏览”按钮选择刚才生成的文件,点击“开始排序”按钮 清除事务日志: • 运行本程序,在主界面上选择数据库,点击“清除日志”按钮 数据导出: • 运行本程序,在主界面上选择数据库,点击“数据导出”按钮进入数据导出界面 • 导出XML:在数据导出界面中选择要导出的数据表,点击“导出XML”按钮,选择要保存的文件后等待导出结束即可;导出的结果是XML文件,该文件可以用“数据导入”功能导入到目标数据库。 • 导出SQL:在数据导出界面中选择要导出的数据表,点击“导出SQL”按钮,选择要保存的文件后等待导出结束即可;导出的结果是SQL脚本,该脚本可以用查询分析器执行。 数据导入: • 运行本程序,在主界面上选择数据库,点击“数据导入”按钮进入数据导入界面 • 进入界面时会要求您选择数据文件,您也可以点击“打开XML数据文件”选择其他的数据文件 • 在数据导入界面中选择要导入的数据表,点击“数据检测”按钮可以检查目标数据库中是否有已存在的数据 • 在数据导入界面中选择要导入的数据表,点击“导入数据”按钮可以将所选数据导入到目标数据库 • 说明:导入过程中会自动处理Identity列,并且会根据表之间的依赖关系,先导入主键表再导入外键表 作者联系方式: Email : xian@vip.163.com Blog : http://www.cnblogs.com/happyprogram/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值