How to connect to the database after the loss of mysql.sock
Security code: it is impossible to have inner peace without a considerable degree of loneliness.
[phenomenon]
The mysql.sock was deleted, making it impossible to connect to the database.
[root@MySQL-01] # mysql-uroot-pEnter password:ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ tmp/mysql.sock' (2)
Prompt cannot connect to MySQL server through mysql.sock.
[solution]
Scenario 1: restart the database to recreate the mysql.sock.
Plan 2: if you can't restart the database temporarily, you can connect to the database through TCP protocol.
MySQL defaults to using UNIX socket file connections instead of TCP/IP from. Starting with MySQL4.1, you can use-- protocol=TCP | SOCKETPIPE | MEMORY to connect to the database.
[root@MySQL-01] # mysql-uroot-p-- protocol=TCPEnter password:Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 16127Server version: 5.6.36-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql >