MYSQL Startup error: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)
[root@iZ2zei01n7f2wrecqn5249Z ~]# sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysqladmin -u root password '123456'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@iZ2zei01n7f2wrecqn5249Z ~]# sudo mysqladmin -u root password '123456'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@iZ2zei01n7f2wrecqn5249Z ~]# lsof -i:3306
-bash: lsof: command not found
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -uroot -h 127.0.0.1 -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -uroot -h 127.0.0.1 -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
[root@iZ2zei01n7f2wrecqn5249Z ~]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 950/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 969/master
tcp6 0 0 ::1:25 :::* LISTEN 969/master
[root@iZ2zei01n7f2wrecqn5249Z ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@iZ2zei01n7f2wrecqn5249Z ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-11-01 19:27:48 CST; 14s ago
Process: 1724 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 1664 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 1723 (mysqld_safe)
CGroup: /system.slice/mysqld.service
├─1723 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─1890 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/...
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Support MySQL by buying support/licenses at http://shop.mysql.com
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Note: new default config file not created.
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Please make sure your config file is current
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: WARNING: Default config file /etc/my.cnf exists on the system
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: This file will be read by default by the MySQL server
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: If you do not want to use this, either remove it, or use the
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: --defaults-file argument to mysqld_safe when starting the server
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysqld_safe[1723]: 211101 19:27:47 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysqld_safe[1723]: 211101 19:27:47 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 01 19:27:48 iZ2zei01n7f2wrecqn5249Z systemd[1]: Started MySQL Community Server.
Start it.
service mysqld start
Recheck status
service mysqld status
Just as shown above
set the password
mysqladmin -u root password '123456'
Sign in
mysql -u root -p
Read More:
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- MYSQL Enter password:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- Centos7 Initialize mysql Error: Could not open file ‘/usr/local/mysql/log/mysqld.log‘ for error logging: Per
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- Ubuntu ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111)
- Mysql8.02/ubuntu 20 ERROR 1449 (HY000) [How to Solve]
- MySQL Error: errorCode 1130, state HY000 [How to Solve]
- linux mysql ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
- After installing mysql5.7 on centos7, an error 1045 (28000) is reported: access denied for user ‘root’ @’localhost ‘(using PAS)
- MySQL 8.0 error 1114 (HY000): the table’sbtest1’is full (Fixed)
- mysql ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executin
- mac brew install mysql ‘/tmp/mysql.sock’ (2) [How to Solve]
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- MySQL Install Error: MySQL error 1042: Unable to connect to any of the specified MySQL hosts