分页: 1 / 1

mysql 数据库链接

发表于 : 2018-04-10 15:32
maquansheng
ubuntu 17.10
mysql 5.7.21

修改 /etc/mysql/mysql.conf.d/mysqld.cnf
port=3316

链接数据库:show variables like '%port%';
显示修改正确

问题:使用 mysql --port=任意数字 都可以顺利登录到 mysql 中

Re: mysql 数据库链接

发表于 : 2018-04-22 0:17
astolia
不读文档想当然的结果,客户端走的是本地socket https://dev.mysql.com/doc/refman/5.7/en/connecting.html
For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port or -P option is given to specify a port number. To ensure that the client makes a TCP/IP connection to the local server, use --host or -h to specify a host name value of 127.0.0.1, or the IP address or name of the local server. You can also specify the connection protocol explicitly, even for localhost, by using the --protocol=TCP option.