暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

mysqladmin(MySQL管理工具)

原创 ming 2022-11-08
432

《深入浅出MySQL》PDF文字版(全),http://www.linuxidc.com

mysqladmin 是一个执行管理操作的客户端程序。可以用它来检查服务器的配置和当前的状 态,创建并删除数据库等。它的功能和 mysql 客户端非常类似,主要区别在于它更侧重于一 些管理方面的功能,比如关闭数据库。
mysqladmin 的用法如下:

使用方法和常用的选项和 mysql 非常类似,这里就不再赘述。这里将可以执行的命令行简单 列举如下:

shell> mysqladmin [options] command [command-options] [command [command-options]] ...

Create a new database
Instruct server to write debug information to log Delete a database and all its tables
Gives an extended status message from the server
Flush all cached hosts
Flush all logs
Clear status variables
Flush all tables
Flush the thread cache
Reload grant tables (same as reload)
Kill mysql threads
Change old password to new-password, MySQL 4.1 hashing.

create databasename
debug
drop databasename
extended-status
flush-hosts
flush-logs
flush-status
flush-tables
flush-threads
flush-privileges
kill id,id,...
password new-password
old-password new-password Change old password to new-password in old format.

ping
processlist
reload
refresh
shutdown
status
start-slave
stop-slave
variables
version
复制

Check if mysqld is alive
Show list of active threads in server
Reload grant tables
Flush all tables and close and open logfiles Take server down
Gives a short status message from the server Start slave
Stop slave
Prints variables available
Get version info from server

这里简单举一个关闭数据库的例子:
复制

25.4 mysqlbinlog(日志管理工具) 由于服务器生成的二进制日志文件以二进制格式保存,所以如果要想检查这些文件的文本格

式,就会用到 mysqlbinlog 日志管理工具。
297

[root@localhost test]# mysqladmin -uroot -p shutdown Enter password:

《深入浅出MySQL》PDF文字版(全),http://www.linuxidc.com

mysqlbinlog 的具体用法如下:
shell> mysqlbinlog [options] log-files1 log-files2...

option 有很多选项,常用的如下:
 -d, --database=name 指定数据库名称,只列出指定的数据库相关操作。
 -o, --offset=# 忽略掉日志中的前 n 行命令
 -r, --result-file=name 将输出的文本格式日志输出到指定文件
 -s, --short-form 显示简单格式,省略掉一些信息
 --set-charset=char-name:在输出为文本格式时,在文件第一行加上 set names char-name, 这个选项在某些情况下装载数据时,非常有用。
 --start-datetime=name –stop-datetime=name:指定日期间隔内的所有日志
 --start-position=# --stop-position=#:指定位置间隔内的所有日志 下面举一个例子说明这些选项的使用:

(1)创建新日志,对 mysql 和 test 数据库做不同的 DML 操作。

[root@localhost mysql]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.41-community-log MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> flush logs;
Query OK, 0 rows affected (0.10 sec)

mysql> use mysql
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Database changed
mysql> revoke process on *.* from z3@'%'; Query OK, 0 rows affected (0.00 sec)

mysql> use test
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Database changed
mysql> truncate table t2;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t2 values(1); Query OK, 1 row affected (0.00 sec)

(2)不加任何参数,显示所有日志(粗体字显示上一步执行过的 SQL)。

[root@localhost mysql]# mysqlbinlog localhost-bin.000033 /*!40019 SET @@session.max_insert_delayed_threads=0*/;

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论