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博客 ” ,链接:https://blog.itpub.net/29291882/viewspace-1104453/
,如需转载,请注明出处,否则将追究法律责任。