Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to log in to mysql locally using a port number

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces how to use the port number to log in to mysql locally. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Recently, when I logged in locally using linux, I found that the login could not be done properly, and the following error message was reported:

[root@xxxx] # mysql-h localhost-u root-p-P 3306

Enter password:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ tmp/mysql.sock' (2)

Analysis: use mysql-- verbose-- help to analyze, only to find that the corresponding values of port and socket are both 0 or empty, that is, there are no default parameters.

[root@UHDEV013] # mysql-verbose-help | grep socket-protocol=name The protocol to use for connection (tcp, socket, pipe,-S,-- socket=name The socket file to use for connection. The buffer size for TCP/IP and socket communication.socket [root@xxxxx ~] # mysql-- verbose-- help | grep port-P,-- port=# Port number to use for connection or 0 for default to, inport 0

When logging in to mysql, you need to find the relevant parameters from the configuration file before you can get the default parameters. The location of the parameter file is as follows:

For the direct use of the parameters appended with-P in the command exercise, why not, I do not know why.

[root@UHDEV013] # mysql-- verbose-- help | grep my.cnf order of preference, my.cnf, $MYSQL_TCP_PORT,/etc/my.cnf / etc/mysql/my.cnf / usr/haier/mysql/etc/my.cnf / usr/haier/mysql/my.cnf ~ / .my.cnf

Solution:

In the / etc/my.cnf file, you can add the socket parameter to [client], but only the port parameter does not work.

On how to use the local port number to log in to mysql to share here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report