MySQLマニュアル14_共通ツール

ツール1:mysql

连接本地mysql:
mysql -u root -p

连接远程mysql:
mysql -h 118.31.106.51 -P 3306 -u root -p

连接远程mysql:
mysql -h118.31.106.51 -P3306 -uroot -p123456

不需要进入MySQL的命令行就SQL语句(用于批处理,shell脚本):
mysql -uroot -p105217 blublog -e "select * from t_comment";

ツール2:mysqladmin

mysqladminは、管理操作を実行するクライアントプログラムです。サーバーの構成と現在のステータスの確認、データベースの作成と削除などに使用できます。

mysqladmin -uroot -p123456 create db01;

mysqladmin -uroot -p105217 create db01;

ツール3:mysqlbinlog

mysqlによって生成されたログはバイナリ形式で保存されます。これらのログを表示するには、mysqlbinlogツールが必要です

ツール4:mysqldump

データベースのバックアップまたは異なるデータベース間のデータ移行を実行するために使用されます

使用例:

mysqldump -uroot -p123456 blublog t_comment > t_comment.sql

mysqldump -uroot -p105217 blublog --add-drop-table > blublog.sql

参数 -d 表示只生成创建表结构的语句:
mysqldump -uroot -p123456 -d blublog > blublog.sql

参数 -t 表示只生成插入数据的语句:
mysqldump -uroot -p123456 -t blublog t_user > t_user.sql

参数 -T 必须加目录,自动生成两个文件:一个.sql文件,创建表结构的语句;一个.txt文件,数据文件
mysqldump -uroot -p123456 -T /tmp blublog t_blog

ツール5:mysqlimport

mysqldumpおよび-Tパラメータの後にエクスポートされた.txtテキストファイルをインポートするために特別に使用されるクライアントデータインポートツール

mysqlimport -uroot -p123456 blublog  /tmp/t_blog.txt

ツール6:mysqlsource

SQLファイルをインポートし、SQLファイル内のすべてのステートメントを実行します(テーブル構造とデータ)

source /tmp/t_comment.sql

ツール7:mysqlshow

どのデータベース、データベース内のテーブル、テーブル内の列またはインデックスが存在するかなどの要約情報をすばやく検索するために使用されるクライアントオブジェクト検索ツール

[root@izbp10tup89om84qulgxbsz ~]# mysqlshow -uroot -p123456 --count
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
+--------------------+--------+--------------+
|     Databases      | Tables |  Total Rows  |
+--------------------+--------+--------------+
| blublog            |      7 |          177 |
| information_schema |     73 |        22536 |
| mysql              |     33 |         3273 |
| performance_schema |    104 |       275191 |
| sys                |    101 |         5121 |
+--------------------+--------+--------------+
[root@izbp10tup89om84qulgxbsz ~]# mysqlshow -uroot -p123456 blublog --count
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
Database: blublog
+--------------------+----------+------------+
|       Tables       | Columns  | Total Rows |
+--------------------+----------+------------+
| hibernate_sequence |        1 |          1 |
| t_blog             |       17 |         19 |
| t_blog_tags        |        2 |         90 |
| t_comment          |        9 |         41 |
| t_tag              |        2 |          9 |
| t_type             |        2 |         16 |
| t_user             |        9 |          1 |
+--------------------+----------+------------+
[root@izbp10tup89om84qulgxbsz ~]# mysqlshow -uroot -p123456 blublog t_user -i
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
Database: blublog  Wildcard: t_user
+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+--------------------+---------+
| Name   | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation       | Checksum | Create_options     | Comment |
+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+--------------------+---------+
| t_user | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         |                | 2020-08-24 22:57:11 |             |            | utf8_general_ci |          | row_format=DYNAMIC |         |
+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+--------------------+---------+

おすすめ

転載: blog.csdn.net/BLU_111/article/details/108326233