`

MariaDB_mysqladmin

 
阅读更多

mysqladmin

via: https://mariadb.com/kb/en/mysqladmin/

 

mysqladmin is an administration program for the mysqld daemon. It can be used to:

  • Monitor what the MySQL clients are doing (processlist)
  • Get usage statistics and variables from the MariaDB / MySQL server
  • Create/drop databases
  • Flush (reset) logs, statistics and tables
  • Kill running queries.
  • Stop the server (shutdown)
  • Start/stop slaves
  • Check if the server is alive (ping)

Usage

mysqladmin [OPTIONS] command command....

mysqladmin Options

Option Description
-c, --count=# Number of iterations to make. This works with -i (--sleep) only.
--debug-check Check memory and open file usage at exit.
--debug-info Print some debug info at exit.
-f, --force Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs.
-C, --compress Use compression in server/client protocol.
--character-sets-dir=name Directory for character set files.
--default-character-set=name Set the default character set.
-?, --help Display this help and exit.
-h, --host=name Connect to host.
-b, --no-beep Turn off beep on error.
-p, --password[=name] Password to use when connecting to server. If password is not given it's asked from the tty.
-P, --port=# Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306).
--protocol=name The protocol to use for connection (tcp, socket, pipe, memory).
-r, --relative Show difference between current and previous values when used with -i. Currently only works with extended-status.
-O, --set-variable=name Change the value of a variable. Please note that this option is deprecated; you can set variables directly with--variable-name=value.
-s, --silent Silently exit if one can't connect to server.
-S, --socket=name The socket file to use for connection.
-i, --sleep=# Execute commands repeatedly with a sleep between.
--ssl Enable SSL for connection (automatically enabled with other flags).Disable with '--skip-ssl'.
--ssl-ca=name CA file in PEM format (check OpenSSL docs, implies --ssl).
--ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).
--ssl-cert=name X509 cert in PEM format (implies --ssl).
--ssl-cipher=name SSL cipher to use (implies --ssl).
--ssl-key=name X509 key in PEM format (implies --ssl).
--ssl-verify-server-cert Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default.
-u, --user=name User for login if not current user.
-v, --verbose Write more information.
-V, --version Output version information and exit.
-E, --vertical Print output vertically. Is similar to '--relative', but prints output vertically.
-w, --wait[=#] Wait and retry if connection is down.
--connect_timeout=#  
--shutdown_timeout=#  

mysqladmin Variables (--variable-name=value)

Variables and boolean options {FALSE|TRUE}  Value (after reading options)
count 0
debug-check FALSE
debug-info FALSE
force FALSE
compress FALSE
character-sets-dir (No default value)
default-character-set (No default value)
host (No default value)
no-beep FALSE
port 3306
relative FALSE
socket /var/run/mysqld/mysqld.sock
sleep 0
ssl FALSE
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cert (No default value)
ssl-cipher (No default value)
ssl-key (No default value)
ssl-verify-server-cert FALSE
user (No default value)
verbose FALSE
vertical FALSE
connect_timeout 43200
shutdown_timeout 3600

mysqladmin Default Options

Default options are read from the following files in the given order:

  1. /etc/my.cnf
  2. /etc/mysql/my.cnf
  3. /usr/etc/my.cnf
  4. ~/.my.cnf

The following groups are read:

  1. mysqladmin
  2. client
  3. client-server
  4. client-mariadb

The following options may be given as the first argument:

Option Description
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

mysqladmin Commands

Command is one or more of: (Commands may be shortened)

Command Description
create databasename Create a new database
debug Instruct server to write debug information to log
drop databasename Delete a database and all its tables
extended-status Gives an extended status message from the server
flush-all-statistics Flush all statistics tables
flush-all-status Flush status and statistics
flush-client-statistics Flush client statistics
flush-hosts Flush all cached hosts
flush-index-statistics Flush index statistics
flush-logs Flush all logs
flush-privileges Reload grant tables (same as reload)
flush-slow-log Flush slow query log
flush-status Clear status variables
flush-table-statistics Clear table statistics
flush-tables Flush all tables
flush-threads Flush the thread cache
flush-user-statistics Flush user statistics
kill id,id,... Kill mysql threads
password new-password Change old password to new-password, MySQL 4.1 hashing.
old-password new-password Change old password to new-password in old format.
ping Check if mysqld is alive
processlist Show list of active threads in server
reload Reload grant tables
refresh Flush all tables and close and open logfiles
shutdown Take server down; see also SHUTDOWN
status Gives a short status message from the server
start-slave Start slave
stop-slave Stop slave
variables Prints variables available
version Get version info from server

Typical example usage

Quick check of what the server is doing:

shell> mysqladmin status
Uptime: 8023  Threads: 1  Questions: 14  Slow queries: 0  Opens: 15  Flush tables: 1  Open tables: 8  Queries per second avg: 0.1
shell> mysqladmin processlist
+----+-------+-----------+----+---------+------+-------+------------------+
| Id | User  | Host      | db | Command | Time | State | Info             |
+----+-------+-----------+----+---------+------+-------+------------------+
....
+----+-------+-----------+----+---------+------+-------+------------------+

More extensive information of what is happening 'just now' changing (great for troubleshooting a slow server):

shell> mysqladmin --relative --sleep=1 extended-status | grep -v " 0 "

Check the variables for a running server:

shell> mysqladmin variables | grep datadir
| datadir                                  | /my/data/ |

Other ways to stop mysqld (unix)

If you get the error:

mysqladmin: shutdown failed; error: 'Access denied; you need (at least one of) the SHUTDOWN privilege(s) for this operation'

It means that you didn't use mysqladmin with a user that has the SUPER or SHUTDOWN privilege.

If you don't know the user password, you can still take the mysqld process down with a system killcommand:

kill -SIGTERM pid-of-mysqld-process

The above is identical to mysqladmin shutdown.

On windows you should use:

NET STOP MySQL

See also

  • mytop, a 'top' like program for MariaDB/MySQL that allows you to see what the server is doing. A mytop optimized for MariaDB is included in MariaDB 5.3
分享到:
评论

相关推荐

    安装mariadb数据库命令

    ### 安装MariaDB数据库命令详解 #### 一、MariaDB简介 MariaDB是一个开源的关系型数据库管理系统(RDBMS),由MySQL的创始人Michael Widenius领导开发,旨在提供一个完全兼容MySQL且更加开放的数据库解决方案。...

    mariadb-5.5.60-linux-x86_64.tar.gz

    MariaDB 5.5.60支持多种数据库管理工具,如`mysqladmin`用于服务器管理,`mysql`命令行客户端进行查询,以及`mysqldump`用于数据备份。启动和停止服务可以使用系统特定的服务管理命令,比如`systemctl start/stop ...

    mariadb-10.11.2-winx64

    - `mysqladmin`命令行工具可用于管理数据库服务,如重启、停止和检查状态。 7. **开发和应用程序连接** - 开发者可以使用各种编程语言(如Python、Java、PHP等)的库来连接和操作MariaDB。 - JDBC驱动(Java ...

    mariadb-10.6.5-linux-systemd-x86_64.tar.gz

    - MariaDB提供了一系列管理工具,如`mysqldump`用于备份,`mysqladmin`用于服务器控制,`mysql`客户端用于查询和管理数据库。 10. **社区支持**: - 作为开源项目,MariaDB拥有庞大的开发者社区和丰富的文档资源...

    mariadb-5.5.66-linux-x86_64.tar.gz

    8. **监控与优化**: MariaDB提供了监控工具如mysqladmin和性能_schema,可以帮助管理员监控数据库状态,识别性能瓶颈,并进行相应的优化。 9. **社区支持**: 作为开源项目,MariaDB有活跃的社区支持,用户可以通过...

    mariadb-10.10.3-linux-systemd-x86-64.tar.gz

    7. **监控和管理工具**:包括命令行工具如`mysqldump`, `mysqladmin`, `mysql`,以及图形界面工具如phpMyAdmin,帮助用户轻松管理和维护数据库。 在使用这个压缩包进行安装时,通常会涉及到解压、配置、初始化...

    mariadb-10.6.7-winx64.7z

    8. **工具集**:MariaDB提供了一系列的管理工具,如mysqladmin,mysqldump,mysqlpump等,帮助用户进行备份、恢复、监控等操作。 9. **X Protocol**:这是MariaDB引入的新协议,允许开发人员使用任何编程语言与...

    无涯教程(LearnFk)-MariaDB教程离线版.pdf

    如果安装成功,即可使用mysqladmin命令查看版本信息。之后,设置MariaDB的root密码,并使用新设置的凭证连接到服务器进行操作。 MariaDB的数据类型包括了数字类型、日期和时间类型以及字符串类型等。这些数据类型在...

    MariaDB-10.4.8.stable-CentOS7.x.rar

    - 使用`mysqladmin`工具检查服务器状态,如`mysqladmin -u root -p status`。 - 定期运行`OPTIMIZE TABLE`命令优化表结构和索引。 8. **安全性** - 使用`GRANT`和`REVOKE`命令管理用户权限。 - 开启SSL连接以...

    MariaDB 10.3.7 win64 zip安装包

    - 管理工具如`mysqladmin`和`mysql`命令行客户端可用于管理数据库,执行查询和维护任务。 - `mysqldump`用于备份数据,`mysqlimport`则用于导入备份。 - MariaDB还支持多种图形界面管理工具,如phpMyAdmin、MySQL...

    database-mariadb-10.3.7.zip

    安装完成后,通过命令行工具`mysql`或`mysqladmin`可以进行数据库的创建、用户管理以及性能监控。 在使用MariaDB时,你可以像操作MySQL一样,通过SQL语句来创建表、插入数据、执行查询、更新和删除记录。MariaDB...

    MariaDB Galera集群写入测试.pdf

    MariaDB Galera集群是一种高可用性和强一致性的分布式数据库解决方案,尤其适合对数据一致性有严格要求的应用场景。在Galera集群中,所有的节点都是主节点,数据写入会在所有节点间实时同步,确保数据的一致性。这篇...

    mariadb-ha软件包

    4. **监控和管理工具**:"mariadb-ha"软件包可能还包括用于监控数据库状态、检查复制健康状况、故障切换和恢复的工具,如`mysqlcheck`, `mysqladmin`, `pt-online-schema-change`等。 5. **安全性和性能优化**:...

    mariadb-5.5.24-linux-x86_64.tar.gz

    1. **bin**:存放可执行文件,如`mysql`客户端、`mysqldump`备份工具、`mysqladmin`管理命令等。 2. **include**:包含头文件,供开发人员在编写连接MariaDB的应用程序时使用。 3. **lib**:包含库文件,这些库文件...

    CentOS7.4搭建利用Rsyslog+LogAnalyzer+MariaDB部署日志服务器

    # mysqladmin -u root password '123456' ``` 4. **测试PHP运行环境**: ``` # cat > /var/www/html/index.php << EOF > > phpinfo(); > ?> > EOF ``` #### 五、服务器软件安装及配置 1. **安装Rsyslog...

    Linux服务器下MariaDB 10自动化安装部署

    /usr/local/mariadb-10.1.16/bin/mysqladmin -u root password "$mysqlrootpwd" ``` 4. 启动MariaDB服务: ```bash /usr/local/mariadb-10.1.16/bin/mysqld_safe --datadir=/data/mysql & ``` 5. 创建系统...

    MariaDB(MySQL)创建、删除、选择及数据类型使用详解

    在本文中,我们将深入探讨MariaDB,它是MySQL的一个分支,由开源社区维护并致力于保持与MySQL的兼容性。MariaDB的主要目标是提供一个无需任何修改就能替代MySQL的解决方案。此外,我们还将学习如何在MariaDB中创建、...

    2021.6.8-网络安全CentOS-安装MySQL(MariaDB).zip

    10. **监控和维护**:定期检查MariaDB的状态,确保数据的安全性和系统的稳定性,可以使用`systemctl status mariadb`查看服务状态,或者使用`mysqladmin variables`查看服务器变量。 以上就是在网络安全环境中,在...

    详解Centos 使用YUM安装MariaDB

    首先,本文介绍的是在Centos系统下使用YUM(Yellowdog Updater, Modified)工具安装MariaDB数据库的详细步骤。MariaDB是MySQL的一个分支,由MySQL的原作者以及部分开发者共同开发,旨在保持开源,同时也提供更好的...

    Mariadb5.5 CentOS6 rpm安装包

    环境:CentOS 6.8 Mariadb:5.5.61 下载 common compat client server四个包 删除相关的mysql包; rpm -qa|grep mysql 然后 yum remove mysqlxxx rpm -i --force --nodeps common.rpm rpm -i --force --nodeps ...

Global site tag (gtag.js) - Google Analytics