mysql 連線方式
1:tcp/ip 套接字方式
這種方式會在tcp/ip 連線上建立乙個基於網路的連線請求,一般是client連線跑在server上的mysql例項,2臺機器通過乙個tcp/ip 網路連線。
c:\users\gechong>mysql -h
192.168.
1.10 -uroot -p
enter password: *******
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id
is6server version:
5.5.
20-log mysql community server (gpl)
2000,
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>
這裡的客戶端是windows,向ip為192.168.1.10 的伺服器上的mysql例項發起了tcp/ip請求,連線成功後就可以使用mysql了。
可以檢視:
mysql> select user,host,password from mysql.user \g
***************************
1. row ***************************
user: root
host: localhost
password: *11b9aca21786f766739d0eb1483c5f64212b81ac
***************************
2. row ***************************
user: root
host:
127.0.
0.1password: *11b9aca21786f766739d0eb1483c5f64212b81ac
***************************
3. row ***************************
user: gechong
host: localhost
password: *7ae39be5035d5c32361400ff7dedd757aa76896a
3 rows
inset (
0.02 sec)
這張許可權表清楚的顯示了mysql允許哪些使用者在哪些ip段內連線
2:unix域套接字
unix域套接字並不是網路協議,所以只能在mysql客戶端和資料庫例項在一台伺服器上使用,使用者可以在配置檔案中指定套接字檔案
--socket=/tmp/mysql.sock
mysql> show variables like
'socket
';
+---------------+-----------------+
| variable_name | value |
+---------------+-----------------+
| socket | /tmp/mysql.sock |
+---------------+-----------------+
1 row
inset (
0.00 sec)
#mysql -uroot -s/tmp/mysql.sock
mysql連線方式
tcp ip 當客戶端和mysql例項不在同一臺伺服器上時,兩台機器通過tcp ip網路連線 mysql h192.168.74.128 uroot p需要注意在通過tcp ip連線時,mysql會先檢查一張許可權檢視,用來判斷客戶端ip是否允許連線到例項 mysql select host,use...
MySQL 連線方式
mysql 連線方式 1 tcp ip 套接字方式 這種方式會在tcp ip 連線上建立乙個基於網路的連線請求,一般是client連線跑在server上的mysql例項,2臺機器通過乙個tcp ip 網路連線。c users gechong mysql h 192.168.1.10 uroot p ...
mysql 連線 MySQL的連線方式
連線mysql操作是連線程序和mysql資料庫例項進行通訊。從開發的角度來說,本質上是程序通訊。常用的程序通訊方式有管道 命名管道 命名字 tcp ip套接字 unix網域名稱套接字。mysql提供的連線方式從本質上看都是上述提及的程序通訊方式。tcp ip tcp ip套接字方式是mysql在任何...