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
-c, |
Number of iterations to make. This works with -i ( ) only. |
|
Check memory and open file usage at exit. |
|
Print some debug info at exit. |
-f, |
Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs. |
-C, |
Use compression in server/client protocol. |
|
Directory for character set files. |
|
Set the default character set. |
-?, |
Display this help and exit. |
-h, |
Connect to host. |
-b, |
Turn off beep on error. |
-p, |
Password to use when connecting to server. If password is not given it's asked from the tty. |
-P, |
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). |
|
The protocol to use for connection (tcp, socket, pipe, memory). |
-r, |
Show difference between current and previous values when used with -i. Currently only works with extended-status. |
-O, |
Change the value of a variable. Please note that this option is deprecated; you can set variables directly with . |
-s, |
Silently exit if one can't connect to server. |
-S, |
The socket file to use for connection. |
-i, |
Execute commands repeatedly with a sleep between. |
|
Enable SSL for connection (automatically enabled with other flags).Disable with ' '. |
|
CA file in PEM format (check OpenSSL docs, implies ). |
|
CA directory (check OpenSSL docs, implies ). |
|
X509 cert in PEM format (implies ). |
|
SSL cipher to use (implies ). |
|
X509 key in PEM format (implies ). |
|
Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default. |
-u, |
User for login if not current user. |
-v, |
Write more information. |
-V, |
Output version information and exit. |
-E, |
Print output vertically. Is similar to ' ', but prints output vertically. |
-w, |
Wait and retry if connection is down. |
|
|
|
mysqladmin Variables (--
variable-name=value
)
--
variable-name=valuecount |
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:
/etc/my.cnf
/etc/mysql/my.cnf
/usr/etc/my.cnf
~
/.my.cnf
The following groups are read:
mysqladmin
client
client-server
client-mariadb
The following options may be given as the first argument:
|
Print the program argument list and exit. |
|
Don't read default options from any option file. |
|
Only read default options from the given file #. |
|
Read this file after the global files are read. |
mysqladmin Commands
Command is one or more of: (Commands may be shortened)
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 kill
command:
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是一个开源的关系型数据库管理系统(RDBMS),由MySQL的创始人Michael Widenius领导开发,旨在提供一个完全兼容MySQL且更加开放的数据库解决方案。...
MariaDB 5.5.60支持多种数据库管理工具,如`mysqladmin`用于服务器管理,`mysql`命令行客户端进行查询,以及`mysqldump`用于数据备份。启动和停止服务可以使用系统特定的服务管理命令,比如`systemctl start/stop ...
- `mysqladmin`命令行工具可用于管理数据库服务,如重启、停止和检查状态。 7. **开发和应用程序连接** - 开发者可以使用各种编程语言(如Python、Java、PHP等)的库来连接和操作MariaDB。 - JDBC驱动(Java ...
- MariaDB提供了一系列管理工具,如`mysqldump`用于备份,`mysqladmin`用于服务器控制,`mysql`客户端用于查询和管理数据库。 10. **社区支持**: - 作为开源项目,MariaDB拥有庞大的开发者社区和丰富的文档资源...
8. **监控与优化**: MariaDB提供了监控工具如mysqladmin和性能_schema,可以帮助管理员监控数据库状态,识别性能瓶颈,并进行相应的优化。 9. **社区支持**: 作为开源项目,MariaDB有活跃的社区支持,用户可以通过...
7. **监控和管理工具**:包括命令行工具如`mysqldump`, `mysqladmin`, `mysql`,以及图形界面工具如phpMyAdmin,帮助用户轻松管理和维护数据库。 在使用这个压缩包进行安装时,通常会涉及到解压、配置、初始化...
8. **工具集**:MariaDB提供了一系列的管理工具,如mysqladmin,mysqldump,mysqlpump等,帮助用户进行备份、恢复、监控等操作。 9. **X Protocol**:这是MariaDB引入的新协议,允许开发人员使用任何编程语言与...
如果安装成功,即可使用mysqladmin命令查看版本信息。之后,设置MariaDB的root密码,并使用新设置的凭证连接到服务器进行操作。 MariaDB的数据类型包括了数字类型、日期和时间类型以及字符串类型等。这些数据类型在...
- 使用`mysqladmin`工具检查服务器状态,如`mysqladmin -u root -p status`。 - 定期运行`OPTIMIZE TABLE`命令优化表结构和索引。 8. **安全性** - 使用`GRANT`和`REVOKE`命令管理用户权限。 - 开启SSL连接以...
- 管理工具如`mysqladmin`和`mysql`命令行客户端可用于管理数据库,执行查询和维护任务。 - `mysqldump`用于备份数据,`mysqlimport`则用于导入备份。 - MariaDB还支持多种图形界面管理工具,如phpMyAdmin、MySQL...
安装完成后,通过命令行工具`mysql`或`mysqladmin`可以进行数据库的创建、用户管理以及性能监控。 在使用MariaDB时,你可以像操作MySQL一样,通过SQL语句来创建表、插入数据、执行查询、更新和删除记录。MariaDB...
MariaDB Galera集群是一种高可用性和强一致性的分布式数据库解决方案,尤其适合对数据一致性有严格要求的应用场景。在Galera集群中,所有的节点都是主节点,数据写入会在所有节点间实时同步,确保数据的一致性。这篇...
4. **监控和管理工具**:"mariadb-ha"软件包可能还包括用于监控数据库状态、检查复制健康状况、故障切换和恢复的工具,如`mysqlcheck`, `mysqladmin`, `pt-online-schema-change`等。 5. **安全性和性能优化**:...
1. **bin**:存放可执行文件,如`mysql`客户端、`mysqldump`备份工具、`mysqladmin`管理命令等。 2. **include**:包含头文件,供开发人员在编写连接MariaDB的应用程序时使用。 3. **lib**:包含库文件,这些库文件...
# mysqladmin -u root password '123456' ``` 4. **测试PHP运行环境**: ``` # cat > /var/www/html/index.php << EOF > > phpinfo(); > ?> > EOF ``` #### 五、服务器软件安装及配置 1. **安装Rsyslog...
/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的一个分支,由开源社区维护并致力于保持与MySQL的兼容性。MariaDB的主要目标是提供一个无需任何修改就能替代MySQL的解决方案。此外,我们还将学习如何在MariaDB中创建、...
10. **监控和维护**:定期检查MariaDB的状态,确保数据的安全性和系统的稳定性,可以使用`systemctl status mariadb`查看服务状态,或者使用`mysqladmin variables`查看服务器变量。 以上就是在网络安全环境中,在...
首先,本文介绍的是在Centos系统下使用YUM(Yellowdog Updater, Modified)工具安装MariaDB数据库的详细步骤。MariaDB是MySQL的一个分支,由MySQL的原作者以及部分开发者共同开发,旨在保持开源,同时也提供更好的...
环境: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 ...