Free tools Windows power users keep installed
One-click scans. No signup required.
The fastest way to fix MySQL error 2002 is to determine whether the client is looking for the wrong Unix socket or whether the MySQL server is not running. Check the service first, copy the socket path shown in the error, compare it with the server configuration, and test that path explicitly. Then try mysql -h 127.0.0.1: a successful TCP connection points to a socket-selection or socket-permission problem, while a failed TCP connection points to the server, port, firewall, or bind configuration.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
What a MySQL socket error means
Messages such as ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/path/mysql.sock' mean that the client could not reach mysqld through the Unix-domain socket it selected. The failure does not by itself prove that the database files are damaged. Common causes are a stopped server, an incorrect socket path or port, a socket file that was removed, different --socket settings on the server and client, or filesystem permissions that prevent access.
As an Amazon Associate I earn from qualifying purchases.
On Unix-like systems, MySQL chooses a Unix socket when no host is supplied or when the host is localhost. A socket is a local filesystem endpoint; it cannot connect to a different machine. Supplying 127.0.0.1 selects TCP/IP instead. That distinction makes a loopback test one of the most useful diagnostic steps.
The MySQL 8.0 Reference Manual documents /tmp/mysql.sock as the default server socket location, but packages and administrators can configure another directory, including locations beneath /var/lib/mysql. Treat the path in the error and the active configuration as authoritative for your installation rather than assuming the documented default.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Socket and TCP connections: the distinction that drives the diagnosis
| Connection attempt | Transport | What it requires | What a failure suggests |
|---|---|---|---|
mysql with no host |
Unix socket | A running local server, matching socket path, and permission to access the socket | Stopped service, missing or wrong socket, mismatched settings, or filesystem permissions |
mysql -h localhost |
Unix socket on Unix systems | The same local socket conditions | The client is still using socket selection even though a host was written |
mysql -h 127.0.0.1 |
TCP/IP loopback | A listening MySQL TCP port and a server configuration that permits TCP | Server, port, firewall, skip_networking, or bind_address issue if it also fails |
| A remote hostname or address | TCP/IP | Network reachability, an allowed port, and a server bind address that accepts the remote interface | Network path, firewall, port, bind, or server configuration problem |
A socket connection is always local to the same operating-system instance. If the database is on another host, a Unix socket on your workstation cannot reach it; use TCP and the server’s network address.
Before changing anything: preserve the evidence
Copy the complete error, especially the path between the quotation marks. Record whether the command used no host, localhost, 127.0.0.1, or a remote name, and note the account and client command. Those details identify the protocol and prevent a successful test from being misinterpreted as a fix for a different connection.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →- Do not delete files in the MySQL data directory.
- Do not remove a socket merely because it is old; first determine whether
mysqldis running and which socket it owns. - Do not reinstall MySQL before checking the service state, error log, active socket setting, and permissions.
- Make configuration edits one at a time so that the next test has a clear result.
Step 1: verify the MySQL service and read the startup error
A missing socket is often a symptom of a server that never started or stopped after a failure. On systemd installations, the unit name commonly differs by package family:
| Installation family | Common systemd unit | Status command |
|---|---|---|
| RPM-based packages | mysqld.service |
systemctl status mysqld.service |
| Debian-based packages | mysql.service |
systemctl status mysql.service |
Use the unit that exists on your system; the names are conventions, not guarantees. A status result showing that the unit is stopped, failed, or repeatedly restarting means the socket investigation must wait until startup is understood. Read the MySQL error log named by your installation’s configuration. Startup errors there can identify an invalid option, a permission problem, an occupied port, or another reason the daemon exited. Fix the startup cause and then rerun the client test.
If the service is active, do not assume the client is using the same socket. A running daemon can listen on one path while a client compiled or configured for another path reports error 2002.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
Step 2: use the path in the error as your starting point
The path printed in the error is the client-side socket path it attempted to open. Compare it with the path configured for mysqld. The documented default is /tmp/mysql.sock, but a package may place the socket elsewhere, such as /var/lib/mysql, and an administrator may have set a custom location.
Look for the server’s socket setting and the client profile’s corresponding setting in the configuration files used by your distribution. Also check how the daemon was launched: a command-line option such as --socket=/path/to/socket overrides an assumption based only on a default file. The important condition is equality: the path where mysqld creates its socket must be the path the client opens.
When the path in the error is absent
If the message names a path that does not exist, first determine whether the service is active. A stopped service will not create a socket. If the service is active but the path is missing, compare the configured path and inspect the error log for a startup or runtime failure. Do not create an empty file with the socket’s name; a Unix socket is created by the running server and an ordinary file cannot substitute for it.
When the path exists but the client still fails
Presence alone is not proof of a usable endpoint. It may be a stale socket left after an unclean shutdown, a socket belonging to another instance, or an object that the client account cannot access. Confirm the owning server process and check directory traversal and socket permissions before removing anything.
Step 3: test the intended socket explicitly
Remove ambiguity about client defaults by passing the path directly. Replace the example path with the path from your configuration or error:
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
- Run
mysqladmin --protocol=SOCKET --socket=/path/to/mysql.sock version. - If that succeeds, connect with the same endpoint using
mysql --protocol=SOCKET --socket=/path/to/mysql.sockand your normal authentication options. - If it fails, repeat the command with the exact path configured for
mysqld, not merely the path you expected from a package default.
A successful mysqladmin result proves that the server is reachable through that socket and that the supplied client can access it. It also gives you a controlled baseline for correcting the default client configuration. If the explicit path works but an ordinary mysql command fails, align the client option or profile so future commands select the working path.
Step 4: align server, client, directory, and socket permissions
Both sides must agree on the socket location. If mysqld starts with --socket=/path/to/socket, every local client that uses a socket must be directed to that same path, either with --socket or with the active client configuration. Conversely, changing only the client path cannot make a server create a socket somewhere else.
Check access at every directory level between the client and the socket. The account running the client needs permission to traverse the directory and open the socket. The server account needs permission to create the socket in its parent directory. A path beneath a private data directory may intentionally be inaccessible to an unprivileged user; changing permissions broadly can weaken database security, so grant only the access required by the intended client account.
After correcting a path or permission, restart the MySQL service through its package unit if a restart is required for the daemon to recreate the endpoint. Then rerun the explicit mysqladmin test before testing applications. Keeping the test command constant makes it clear whether the change affected the connection.
Step 5: check whether cleanup removed the socket
A Unix socket is a filesystem object with a lifecycle tied to the server process. If a cleanup job removes files from /tmp while MySQL is still running, the daemon may continue running while new clients can no longer find the socket. The same symptom can occur after an unclean shutdown if a stale path remains or the daemon recreates the socket elsewhere.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
When the configured socket is under /tmp, review cron jobs, temporary-file cleanup policies, and security software that may delete old-looking entries. The durable remedies are to protect the socket from cleanup or configure it in a directory managed for the database service. Any move requires updating both the server and client settings to the identical new path and restarting the service so the socket is recreated there.
Step 6: compare the socket with a TCP loopback connection
Run a TCP test that bypasses Unix-socket selection:
- Try
mysql -h 127.0.0.1with the same account and authentication options. - If MySQL listens on a non-default port, add that configured port to the command.
- Compare the result with the explicit socket test rather than changing several settings at once.
The documented default MySQL TCP port is 3306; it is a configuration default, not a promise that every installation uses it. A successful 127.0.0.1 connection while the socket attempt fails strongly indicates a socket path, socket lifecycle, or filesystem-access problem. A failed loopback test means the problem is broader than socket selection: inspect whether the server is listening, which port it uses, and whether TCP has been disabled or restricted.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
| Socket test | TCP loopback test | Most likely direction |
|---|---|---|
| Fails | Succeeds | Wrong or deleted socket, mismatched client/server path, or socket permissions |
| Succeeds | Fails | TCP port, skip_networking, bind, or firewall configuration; the socket itself is usable |
| Fails | Fails | Stopped or unhealthy server, incorrect service instance, or simultaneous socket and TCP configuration problems |
| Succeeds | Succeeds | The server offers both transports; investigate the application’s selected host, socket, port, or credentials |
Step 7: troubleshoot TCP, port, and remote connections
When the TCP test fails, verify the port configured for the server and client. MySQL’s default is 3306, but a custom port must be supplied consistently. A client aimed at the wrong port can produce a connection failure even when the server and socket are healthy.
Check skip_networking
If skip_networking is enabled, the server does not accept TCP/IP connections. In that configuration, local clients must use the Unix socket, and remote clients cannot connect over TCP until the setting is changed and the server is restarted according to the installation’s procedure.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Check bind_address
The bind_address setting determines which local interfaces accept TCP connections. A server bound only to a specific address may reject connections sent to another address, including a loopback address that is not covered by the active setting. Confirm the configured bind address and test the exact address the server is intended to serve.
Check firewall rules
For remote connections, a host firewall or network firewall must allow the configured MySQL port between the client and server. A local socket test cannot validate this path because it never traverses the network. Test from the client machine using the server’s actual hostname or address, and make sure the firewall rule matches the selected port rather than assuming 3306.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Common failure patterns and the correct response
The service is stopped
Use the appropriate systemd unit, inspect its status, and read the MySQL error log. Correct the startup error first. Once the unit remains active, confirm the socket path and run the explicit socket test. Starting and stopping the service repeatedly without reading the log can hide the original cause.
localhost fails but 127.0.0.1 works
This pattern selects two different transports on Unix systems. Keep using the TCP command only if TCP is intentional; otherwise correct the socket path or permissions so the normal local command reaches the server through its Unix socket. Check the application configuration as well, because an application may set localhost explicitly even when a command-line test used an address.
Both local forms fail after a package change
Do not assume the package retained the previous socket directory or service name. Check which systemd unit is installed, read the active server configuration, and compare the path printed by the client with the path created by the running daemon. Package-specific defaults can differ even when the MySQL version is similar.
The socket worked until a reboot or cleanup event
Verify that the service starts at boot and that its configured socket directory exists and is writable by the server account. If the path is under /tmp, investigate cleanup policies. Reconfigure both endpoints to a protected directory if temporary-file deletion is the recurring cause.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallAn explicit socket path works, but applications still report error 2002
The application is probably loading a different client profile, environment, or connection option. Put the known-good socket path into that application’s supported configuration, or configure its connection to use TCP deliberately. Test with the application’s own runtime account when permissions differ from your interactive shell.
What not to do
- Do not treat
/tmp/mysql.sockas universal; it is a documented default, not a guarantee. - Do not restart an arbitrary service name. RPM-based and Debian-based installations commonly use different units, and custom packages may use another one.
- Do not delete database files, initialize a new data directory, or reinstall solely because a socket is missing.
- Do not create a symbolic link to a guessed path before confirming that the target socket belongs to the active server. A link can conceal a configuration mismatch and break after the next restart.
- Do not open a firewall port or change bind settings until you have established that TCP is required and identified the correct port.
A repeatable troubleshooting checklist
- Copy the complete error and note the socket path and host option used.
- Check the correct systemd unit:
mysqld.serviceis common on RPM platforms andmysql.serviceon Debian platforms. - If the service failed, read the MySQL error log and resolve the startup cause.
- Compare the client path in the error with the server’s active
socketsetting and any--socketlaunch option. - Run
mysqladmin --protocol=SOCKET --socket=/path/to/mysql.sock versionwith the verified path. - Check directory and socket permissions for the account running the client and the account running
mysqld. - Investigate cleanup processes if the socket is in
/tmpand disappears while the server remains active. - Run
mysql -h 127.0.0.1, adding the configured port when it is not 3306. - If TCP fails, inspect
skip_networking,bind_address, the listening port, and firewall rules. - Retest after each change and record the working transport and path for application configuration.
Final diagnosis
Error 2002 is a connection-path problem, not a single specific fault. Start with the daemon and its log, make the socket path identical on the server and client, verify permissions and socket-file lifecycle, and then use the 127.0.0.1 comparison to decide whether TCP settings also need attention. This sequence separates a local Unix-socket mismatch from a server-wide or network failure without risking the database itself.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




