[MySQL Case] mysql local logon-S is invalid, mysql-s

Source: Internet
Author: User

[MySQL Case] mysql local logon-S is invalid, mysql-s

1.1.1. The-S parameter is invalid when mysql is logged on to the local machine.

[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.


Mysql on the local machine cannot be connected to the command line.

Is this prompt displayed? If you are advised to uninstall mysql, manually delete the installation directory, and then reinstall it, temporarily disable the monitoring function of anti-virus software during installation




In the command line to log on to the local mysql "mysql-h 1921681100-utest-p123", how can this problem be solved?

This is a remote logon on the LAN.
Are you sure you want to log on to the local mysql instance? If yes, it should be
Mysql-utest-p123

Then, even if you log on remotely, it should be
Mysql-h192.168.1.100-utest-p123
No space is allowed between-h and 192.

If you log on remotely, you must enable the remote logon permission of user test. Otherwise, this error is reported, indicating that you do not have the permission and the access is denied.

Related Article

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.