安装
tar -zxvf mysql-utilities-1.6.5.tar.gz
cd mysql-utilities-1.6.5
python ./setup.py build
python ./setup.py install
连接MySQL服务器
使用mysql_config_editor工具添加如下连接信息:
[root@localhost mysql-utilities-1.6.5]# mysql_config_editor set --login-path=instance_3306 --host=localhost --user=root --port=3306 --password
Enter password:
查看链接信息
[root@localhost mysql]# mysql_config_editor print --login-path=instance_3306
[instance_3306]
user = root
password = *****
host = localhost
port = 3306
连接测试
[root@localhost mall]# mysqlserverinfo --server=instance_3306 --format=vertical
# Source on localhost: ... connected.
************************* 1. row *************************
server: localhost:3306
config_file: /etc/my.cnf
binary_log:
binary_log_pos:
relay_log:
relay_log_pos:
version: 5.7.9
datadir: /usr/local/mysql/data/
basedir: /usr/local/mysql
plugin_dir: /usr/local/mysql/lib/plugin/
general_log: OFF
general_log_file:
general_log_file_size:
log_error: /usr/local/mysql/data/localhost.localdomain.err
log_error_file_size: 52825 bytes
slow_query_log: OFF
slow_query_log_file:
slow_query_log_file_size:
使用mysqlfrm 查看frm格式文件
[root@localhost mall]# mysqlfrm --server=instance_3306 account.frm --diagnostic
执行结果如下
CREATE TABLE `account` (
`id` int(11) NOT NULL,
`name` varchar(50) COLLATE `utf8_general_ci` DEFAULT NULL,
`balance` int(255) DEFAULT NULL,
PRIMARY KEY `PRIMARY` (`id`),
KEY `idx_balance` (`balance`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
如果是看本地数据库的文件可不必使用连接即可查看
[root@localhost mall]# mysqlfrm --diagnostic account.frm
# WARNING: Cannot generate character set or collation names without the --server option.
# CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such, it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.
# Reading .frm file for account.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:
CREATE TABLE `account` (
`id` int(11) NOT NULL,
`name` varchar(150) DEFAULT NULL,
`balance` int(255) DEFAULT NULL,
PRIMARY KEY `PRIMARY` (`id`),
KEY `idx_balance` (`balance`)
) ENGINE=InnoDB;
本文详细介绍MySQL实用工具包mysql-utilities的安装步骤,包括tar包解压、编译及安装,并演示如何通过mysql_config_editor配置连接信息,使用mysqlserverinfo进行服务器信息查询,以及利用mysqlfrm工具解析frm格式文件。
3607

被折叠的 条评论
为什么被折叠?



