连接MySQL数据库的两种方式介绍
连接MySQL操作是连接进程和MySQL数据库实例进行通信。从开发的角度来说,本质上是进程通信,常用的进程通信方式有管道、命名管道、命名字、TCP/IP套接字、Unix域名套接字
TCP/IP连接:
TCP/IP套接字连接方式是MySQL在任何平台都提供的一种连接方式,也是网络中使用最多的一种方式。这种方式在TCP/IP连接上建立一个基于网络的连接请求,一般情况下客户端在一台服务器上,而MySQL实例在另外一台服务器上,这两台机器通过TCP/IP网络连接
mysql> use mysql;
Readingtable information for completion of table and column names
Youcan turn off this feature to get a quicker startup with -A
Databasechanged
mysql>select user,host,password from user;
+------+-------------------+-------------------------------------------+
|user | host | password |
+------+-------------------+-------------------------------------------+
|root | localhost |*23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
|root | server.sxkeji.com | |
|root | 127.0.0.1 | |
| | localh