日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MYSQL基础:mysql客户端工具

發(fā)布時(shí)間:2023/12/10 数据库 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MYSQL基础:mysql客户端工具 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.


關(guān)于mysql客戶端工具,和sqlplus一樣通過為用戶提供一個(gè)命令行接口來操作和管理MYSQL服務(wù)器。 本文總結(jié)一下常用的選項(xiàng)和基礎(chǔ)的幾個(gè)設(shè)定技巧。

常用選項(xiàng)

選項(xiàng)縮寫選項(xiàng)選項(xiàng)說明
-e–execute=name執(zhí)行指定命令后退出

常用場(chǎng)景:
在腳本后者程序中嵌入使用,不希望使用交互式的方式使用msql客戶端,執(zhí)行一條指定的語句后退出。

使用例:

# mysql -uroot -pliumiaocn -e "desc mysql.time_zone" mysql: [Warning] Using a password on the command line interface can be insecure. +------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+------------------+------+-----+---------+----------------+ | Time_zone_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | Use_leap_seconds | enum('Y','N') | NO | | N | | +------------------+------------------+------+-----+---------+----------------+ # 選項(xiàng)縮寫選項(xiàng)選項(xiàng)說明
-E–vertical以縱列方式顯示顯示結(jié)果,類似\G的作用

使用例:將見一個(gè)例子以縱列方式顯示

# mysql -uroot -pliumiaocn -E -e "desc mysql.time_zone" mysql: [Warning] Using a password on the command line interface can be insecure. *************************** 1. row ***************************Field: Time_zone_idType: int(10) unsignedNull: NOKey: PRI Default: NULLExtra: auto_increment *************************** 2. row ***************************Field: Use_leap_secondsType: enum('Y','N')Null: NOKey: Default: NExtra: # 選項(xiàng)縮寫選項(xiàng)選項(xiàng)說明
-H–html結(jié)果以HTML方式進(jìn)行保存
-X–xml結(jié)果以XML方式進(jìn)行保存

常用場(chǎng)景:
以HTML頁面或者XML格式方式將執(zhí)行的過程直接生成HTML文件時(shí)可以使用

使用例:

# mysql -uroot -pliumiaocn -H -e "desc mysql.time_zone" mysql: [Warning] Using a password on the command line interface can be insecure. <TABLE BORDER=1><TR><TH>Field</TH><TH>Type</TH><TH>Null</TH><TH>Key</TH><TH>Default</TH><TH>Extra</TH></TR><TR><TD>Time_zone_id</TD><TD>int(10) unsigned</TD><TD>NO</TD><TD>PRI</TD><TD>NULL</TD><TD>auto_increment</TD></TR><TR><TD>Use_leap_seconds</TD><TD>enum('Y','N')</TD><TD>NO</TD><TD></TD><TD>N</TD><TD></TD></TR></TABLE># #

將此輸出的HTML內(nèi)容進(jìn)行保存,用瀏覽器打開,可以看到效果如下所示

選項(xiàng)縮寫選項(xiàng)選項(xiàng)說明
-–prompt=name執(zhí)行提示信息

常用場(chǎng)景:
修改默認(rèn)的mysql>的提示信息,同Linux上的prompt一樣,可以用于提示一些具體的特定信息,比如當(dāng)前用戶,使用的數(shù)據(jù)庫(kù)信息,時(shí)間信息等,可以對(duì)操作者進(jìn)行一定的提醒或者警示作用

使用例:將默認(rèn)的mysql提示改成 hello to liumiaocn mysql。

# mysql -uroot -pliumiaocn --prompt="hello to liumiaocn mysql>" mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 45618 Server version: 5.7.16 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.hello to liumiaocn mysql>

更常見的使用方式比如如下所示:

# mysql -uroot -pliumiaocn --prompt="[\\u@\\h(\\d) \\R:\\m:\\s] mysql>" mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 47427 Server version: 5.7.16 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.[root@localhost((none)) 17:24:04] mysql>use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -ADatabase changed [root@localhost(mysql) 17:24:11] mysql>
  • 時(shí)間相關(guān)信息
轉(zhuǎn)義序列說明
\D完整的日期和時(shí)間
\yYY格式的年
\YYYYY格式的年
\o以數(shù)字方式顯示的月份
\O以字母方式顯示的月份
\w以字母顯示的星期信息
\Pam/pm標(biāo)志
\r12小時(shí)制時(shí)間
\R24小時(shí)制時(shí)間
\m
\s
  • 其他設(shè)定信息
轉(zhuǎn)義序列說明
\u當(dāng)前用戶名
\U包含主機(jī)名的用戶名
\h當(dāng)前主機(jī)
\d當(dāng)前使用的數(shù)據(jù)庫(kù)
\v服務(wù)器的版本號(hào)
\p當(dāng)前端口號(hào)或者socket文件名
\c當(dāng)前輸入行數(shù)
  • 特殊字符
轉(zhuǎn)義序列說明
\t制表符
\l當(dāng)前分隔符
\S分號(hào)
單引號(hào)
"雙引號(hào)
_空格字符
\反斜線
\n換行符

總結(jié)

以上是生活随笔為你收集整理的MYSQL基础:mysql客户端工具的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。