前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MySQL管理工具 mysqladmin 原

MySQL管理工具 mysqladmin 原

作者头像
醉生萌死
发布2018-11-05 14:40:44
1.3K0
发布2018-11-05 14:40:44
举报
文章被收录于专栏:醉生梦死

数据库版本信息

代码语言:javascript
复制
[root@db02 ~]# mysql --version
mysql  Ver 14.14 Distrib 5.6.36, for Linux (x86_64) using  EditLine wrapper

选项 

代码语言:javascript
复制
[root@db02 ~]# mysqladmin --help | less

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-hosts           Flush all cached hosts
flush-logs            Flush all logs
flush-status          Clear status variables
flush-tables          Flush all tables
flush-threads         Flush the thread cache
flush-privileges      Reload grant tables (same as reload)
kill id,id,...        Kill mysql threads
password [new-password] Change old password to new-password in current format
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
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

修改用户密码:

代码语言:javascript
复制
[root@db02 ~]# mysql -uroot -p123 -e 'select user,host,password from mysql.user'
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| root | 127.0.0.1 |                                           |
| root | 10.0.0.%  | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+------+-----------+-------------------------------------------+

修改密码为123456 

代码语言:javascript
复制
[root@db02 ~]# mysqladmin -uroot -p123 password '123456'
Warning: Using a password on the command line interface can be insecure.

# 提示错误,密码不符合
[root@db02 ~]# mysql -uroot -p123 -e 'select user,host,password from mysql.user'
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

# 使用修改后的密码
[root@db02 ~]# mysql -uroot -p123456 -e 'select user,host,password from mysql.user'
Warning: Using a password on the command line interface can be insecure.
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 |                                           |
| root | 10.0.0.%  | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+------+-----------+-------------------------------------------+

使用安全模式关闭数据库

代码语言:javascript
复制
[root@db02 ~]# mysqladmin -uroot -p123456 shutdown
[root@db02 ~]# netstat -lntup | grep mysql
[root@db02 ~]# lsof -i:3306
[root@db02 ~]# 

注:此博客仅供参考!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 数据库版本信息
  • 选项 
  • 修改用户密码:
  • 使用安全模式关闭数据库
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档