[MySQL case] mysql local logon-S failure _ MySQL

Source: Internet
Author: User
The-S parameter is invalid when mysql is logged on to mysql on 111mysql. [environment description] mysql5514 [problem description] Multi-instance 1 instance 2datadirhomemysql_3306homemysql_3307basedirusrs 1.1.1

[Environment description]

Mysql5.5.14

[Problem description]

Multi-instance configuration

Instance 1

Instance 2

Datadir

/Home/mysql_3306

/Home/mysql_3307

Basedir

/Usr

/Usr

Socket

/Home/mysql_3306/mysq. sock

/Home/mysql_3307/mysq. sock

When I log on to instance 2, I connect to instance 1:

Mysql-S/home/mysql_3307/mysql. sock

> Show variables like '% sock % ';

+ --------------- + ----------------------------- +

| Variable_name | Value |

+ --------------- + ----------------------------- +

| Socket |/home/mysql_3306/mysql. sock |

+ --------------- + ----------------------------- +

[Cause]

The-S parameter in the mysql command is used to specify the unix_socket, But mysql obviously does not use the socket at this time.

View the/etc/my. cnf configuration file and find that the [client] domain configuration is as follows:

[Client]

Host = 127.0.0.1

Try to modify host = localhost and comment out host, and log on to mysql again:

Mysql-S/home/mysql_3307/mysql. sock

> Show variables like '% sock % ';

+ --------------- + ----------------------------- +

| Variable_name | Value |

+ --------------- + ----------------------------- +

| Socket |/home/mysql_3307/mysql. sock |

+ --------------- + ----------------------------- +

At this time, the specified instance is logged on normally.

Test logon to mysql again:

Mysql-S/home/mysql_3306/mysql. sock-h 127.0.0.1-P 3307

> Show variables like '% sock % ';

+ --------------- + ----------------------------- +

| Variable_name | Value |

+ --------------- + ----------------------------- +

| Socket |/home/mysql_3307/mysql. sock |

+ --------------- + ----------------------------- +

When logging on to mysql, the specified socket is port 3306, the host is 127.0.0.1, and the port is 3307. after logging on, it connects to the instance with port 3307,

Mysql-S/home/mysql_3307/mysql. sock-h127.0.0.1

> Show variables like '% sock % ';

+ --------------- + ----------------------------- +

| Variable_name | Value |

+ --------------- + ----------------------------- +

| Socket |/home/mysql_3306/mysql. sock |

+ --------------- + ----------------------------- +

When logging on to mysql, the specified socket is port 3307, the host is 127.0.0.1, and the port is not specified. after logging on, the instance connected to port 3306 is used.

In summary, when the mysql client connects to the mysql database, if both socket and host are specified, mysql will use the TCP/IP protocol to log on, and the socket will be ignored at this time, access Port 3306 by default.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.