MySQL管理工具 mysqladmin

數據庫版本信息

[root@db02 ~]# mysql --version
mysql  Ver 14.14 Distrib 5.6.36, for Linux (x86_64) using  EditLine wrapper

選項 

[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

修改用戶密碼:

[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 mysql

[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 |
+------+-----------+-------------------------------------------+

使用安全模式關閉數據庫

[root@db02 ~]# mysqladmin -uroot -p123456 shutdown
[root@db02 ~]# netstat -lntup | grep mysql
[root@db02 ~]# lsof -i:3306
[root@db02 ~]# 

注:此博客僅供參考!sql

相關文章
相關標籤/搜索