The error in the screenshot means that MySQL Workbench (or a similar GUI tool) is unable to connect to your MySQL server using the root
user at localhost:3306
.
🔧 Cause:
The key issue is:
This means the root
password is incorrect, or the root user is not allowed to log in via TCP/IP.
✅ Fix Steps
1. Make sure MySQL server is running
Run this in terminal:
If it's not running, start it with:
2. Try logging in from terminal
If this logs you in without a password, then root is configured with auth_socket plugin.
3. Switch root
to use password-based login (optional)
If you want to log in via Workbench, you'll need to allow password authentication:
Then, test:
4. Use correct credentials in MySQL Workbench
-
Host:
127.0.0.1
-
Port:
3306
-
Username:
root
-
Password: the one you set above
✅ Avoid using localhost
— use 127.0.0.1
to force TCP/IP.
Let me know if you want to create a new MySQL user instead of changing root
.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass'; Query OK, 0 rows affected (0.01 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec) mysql> exit Bye (base) jain@jain-ThinkPad-T440s:~/Downloads$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
You're now getting:
This error means MySQL server is not running, or the socket file is not available at /tmp/mysql.sock
, which is where your client expects it.
✅ Step-by-Step Fix
1. Start MySQL Server
Run:
If it gives:
System has not been booted with systemd as init system
You're likely on a system like MX Linux, which uses SysVinit
or runit
instead of systemd
.
So try:
Then test:
2. Verify Socket Location (Optional)
Check where the MySQL socket is configured:
Or:
You might see:
If so, connect using:
3. Reinstall or Repair MySQL (if needed)
If the server refuses to start, try reinstalling:
Let me know what you get when running:
Or share the output of:
No comments:
Post a Comment