mysql 数据库链接

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
maquansheng
帖子: 1
注册时间: 2018-04-10 15:22

mysql 数据库链接

#1

帖子 maquansheng » 2018-04-10 15:32

ubuntu 17.10
mysql 5.7.21

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

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

问题:使用 mysql --port=任意数字 都可以顺利登录到 mysql 中
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: mysql 数据库链接

#2

帖子 astolia » 2018-04-22 0:17

不读文档想当然的结果,客户端走的是本地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.
回复