MySQL的連接管理及常用參數(shù)

1.MySQL數(shù)據(jù)庫連接

  • 1.1MySQL:是一個典型的c/s結(jié)構(gòu)的軟件應(yīng)用,用服務(wù)端有客戶端,MySQL需要專門的客戶端程序,來連接數(shù)據(jù)庫進行管理和操作的。

2.連接方式

  • 2.1socket (本地登錄使用)
[root@db01 ~]# mysql -uroot -p123  -S  /tmp/mysql.sock           #socket本地登錄方式
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 14
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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.

mysql>

注意:socket登錄的前提,socket文件位置指定準(zhǔn)確,必須要具備XXX@'localhost'相關(guān)的用戶

  • 2.2TCP/IP登錄
[root@db01 ~]# mysql -uzfs -p123456  -h10.0.0.91 -P3306
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 15
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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.

mysql> 
  • 2.3通過軟件工具遠(yuǎn)程登錄
  • 2.3.1SQLyog遠(yuǎn)程連接


    SQLyog遠(yuǎn)程連接
  • 2.3.2Navicat for MySQL遠(yuǎn)程連接連接


    Navicat遠(yuǎn)程連接
  • 2.4MySQL常用參數(shù)介紹
參數(shù) 介紹
-u 用戶名
-p 密碼
-S socket文件目錄
-h IP地址
-P 端口號(默認(rèn)3306)
-e 免交互執(zhí)行MySQL里的命令,不用登錄進去
[root@db01 ~]# mysql -uroot -p123 -e "show databases;"
< 將腳本導(dǎo)入到數(shù)據(jù)庫中
[root@db01 ~]# mysql -uroot -p123<world.sql
  • 2.5MySQL客戶端內(nèi)置功能
參數(shù) 介紹
help 打印幫助
/G 將行轉(zhuǎn)成列顯示
Ctrl+C 返回新的命令行(終止命令)
Ctrl+D,exit,quit 退出登錄
source 導(dǎo)入腳本 (source /root/word.sql)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容