mysql 的連線方式

mhabbyo發表於2014-03-10

 mysql 的localhost 走的是 socket  指定路徑必須要指定socket才能夠進行連線  
如果以127.0.0.1進行登入,必須是3306埠的,否則不能夠成功的


[root@mysql_multi ~]# mysql -uroot -hlocalhost -p -S /data/mysql/mysqldata3307/sock/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.6.14 MySQL Community Server (GPL)

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

[root@mysql_multi ~]# mysql -uroot -h127.0.0.1 -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

因為我的安裝路徑指定的是3307埠

[root@mysql_multi ~]# netstat  -nlp|grep my
tcp        0      0 :::3307                     :::*                        LISTEN      5811/mysqld         
unix  2      [ ACC ]     STREAM     LISTENING     18819  5811/mysqld         /data/mysql/mysqldata3307/sock/mysql.sock


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29291882/viewspace-1104453/,如需轉載,請註明出處,否則將追究法律責任。

相關文章