Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Troubleshoot Common MySQL Problems on Ubuntu Server

Diagnose MySQL on Ubuntu systematically: inspect systemd and error logs, classify permission and port failures, separate socket from TCP tests, verify bind and firewall settings, and fix account authentication without guesswork.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Most MySQL failures on Ubuntu can be isolated without reinstalling the server. Start with systemctl and the journal, read MySQL’s error log, then determine whether the fault is service startup, filesystem access, a Unix socket, TCP listening, firewall policy, or account authentication. Make the smallest change that addresses the observed error, restart once, and verify the resulting listener and client connection.

Use this diagnostic order

Do not begin by repeatedly restarting MySQL or changing several configuration values at once. Each test below answers a different question, and the order preserves useful evidence.

As an Amazon Associate I earn from qualifying purchases.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Failure class Typical evidence First useful check Risk of the first check
Service or startup The unit is inactive, failed, or exits during boot systemctl status and the systemd journal Read-only
Configuration or log Syntax errors, unknown options, or a startup message explaining the exit MySQL error log and the active included configuration Read-only
Filesystem permission Errcode 13 or inability to open the data directory Confirm the data path and its ownership and access controls Read-only until an ownership change is justified
Unix socket ERROR 2002 when using localhost Compare the client socket path with the server’s socket and service state Read-only
TCP or port Connection refused, no listener, or “address already in use” ss, configured port, and bind-address Read-only
Firewall or remote path Local access works but a remote host cannot connect Firewall policy, bind address, and the actual listening port Read-only before opening a rule
Authentication Access denied for user ... Account User, Host, and authentication plugin Read-only until account changes are planned

1. Establish whether the MySQL service is running

Run the status command first. It shows whether systemd considers the unit active, failed, stopped, or repeatedly restarting, and often includes the most recent exit message.

sudo systemctl status mysql

Then read the complete unit journal rather than relying on the abbreviated status output:

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • 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.
sudo journalctl -u mysql

Look at the timestamps around the latest start attempt. A clean stop followed by no new start attempt is different from a daemon that starts and immediately exits. Messages about a missing file, an invalid option, permissions, or a busy endpoint determine the next branch.

Ubuntu also documents the traditional service wrapper. It is useful on installations where an administrator already uses that interface:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo service mysql status
sudo service mysql restart

Do not treat a successful restart command as proof that the server is usable. A command can return while the unit subsequently fails, so always run systemctl status mysql again and inspect the journal after a restart.

2. Read MySQL’s error log before editing configuration

MySQL’s own startup guidance treats the error log as the primary explanation for a failed launch. On Debian-family packages, the files are commonly below /var/log/mysql, but the path can differ. Confirm the active logging setting and included configuration instead of assuming a filename.

sudo ls -l /var/log/mysql
sudo journalctl -u mysql --since "15 minutes ago"

If the directory does not contain the current messages, use the path specified by the active MySQL configuration or the package’s service definition. Read the newest entries first and preserve the original error text; a later “shutdown complete” line can be a consequence, not the cause.

Search for the first error in the failed start sequence. The most useful details are the data directory path, socket path, port number, option name, operating-system error code, and the identity under which the daemon attempted the operation.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • 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

3. Classify startup failures from the exact error

Errcode 13: permission or security access

Errcode 13 means the server process cannot access the data directory or one of its contents. Confirm the configured data directory first; package layouts and custom installations can place it in different locations. Then check that the MySQL service account can traverse the parent directories and read and write the files it needs.

sudo namei -l /path/to/mysql-data
sudo ls -ld /path/to/mysql-data
sudo ls -l /path/to/mysql-data

Replace the example path with the one shown by the error log or active configuration. Check mandatory security controls as well as ordinary Unix ownership and mode bits. A security policy can deny access even when the owner and permissions look correct.

Only after confirming the correct path and package layout should you repair ownership. Use the service account expected by the Ubuntu package, commonly mysql, and change only the affected data directory and files. Do not run the daemon as root as a routine workaround: it hides the underlying access problem and increases the impact of a compromise.

“Address already in use” or a socket bind error

A message such as “Bind on TCP/IP port: Address already in use” means another process already owns the requested TCP endpoint. A Unix-socket bind error similarly means the requested socket path is occupied or unusable. Identify the process before changing the MySQL port or deleting a socket.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ss -ltnp | grep -E 'mysql|3306'

For a custom port, replace 3306 in the pattern. If another MySQL instance or unrelated service owns the port, decide whether that service should stop, whether MySQL should use a different port, or whether the configuration points to an obsolete endpoint. Changing the port without identifying the owner can simply move the collision or break clients that still use the old value.

Configuration and included-file mistakes

Ubuntu’s package commonly loads settings from /etc/mysql/mysql.conf.d/mysqld.cnf, although additional files may be included. Make sure you edit the file that is actually read and that an included drop-in is not overriding it. Change one option at a time. An invalid option or malformed value should be corrected according to the exact error-log message before any network testing.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • 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)

4. Check the data directory and mandatory security controls

Permission repairs are safe only when tied to evidence. Verify all of the following before changing ownership:

  • The configured data directory is the path you are inspecting.
  • The directory and every parent directory are traversable by the MySQL service account.
  • Database files are owned and writable as required by the installed package.
  • The filesystem is mounted read-write and has available space.
  • Mandatory security software has not denied the access shown in the journal or error log.

After a targeted repair, restart the service and immediately recheck the journal. If the error changes from a permission denial to a different startup failure, keep the original evidence and continue with the new failure class rather than applying more ownership changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Separate Unix-socket problems from TCP problems

When a MySQL client uses localhost, it normally attempts a Unix-domain socket instead of TCP. Therefore, ERROR 2002 can mean that mysqld is stopped, the daemon failed before creating its socket, or the client and server are configured with different socket paths. It does not by itself prove that networking or the firewall is broken.

Test the local socket path

First confirm the service and error log. Then compare the socket path configured for the server with the path the client is trying to use. If the server is running but the paths differ, use the configured path explicitly or correct the client configuration so both sides agree.

mysql --socket=/path/from/server-configuration -u username -p

Use the actual socket path shown by the active configuration; the example path is not a universal default.

Force a TCP test

To test a different path, connect to the loopback address explicitly and provide the configured port:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • 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
mysql --host=127.0.0.1 --port=3306 -u username -p

Replace 3306 when the server uses a custom port. If TCP succeeds while localhost fails, focus on socket-path agreement. If both fail, return to service status, the error log, and the listener check rather than changing authentication.

6. Confirm the listener, bind address, and firewall

A running service is not necessarily listening where clients expect. Check the actual TCP listeners:

sudo ss -ltnp | grep -E 'mysql|3306'

The output should show the address and port owned by the MySQL process. Use a pattern matching your custom port when necessary. No matching listener means the daemon did not bind successfully, is listening on another port, or is using only a Unix socket.

Interpret bind-address

On Ubuntu’s packaged layout, bind-address in /etc/mysql/mysql.conf.d/mysqld.cnf controls which local address accepts TCP connections. A loopback-only address permits local TCP tests but prevents remote clients. A specific private interface limits exposure to that network, while a broad address increases the number of reachable interfaces and therefore the security responsibility.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Change the bind address only when the listener and the required connection scope are clear. A remote connection needs all of these conditions at once:

  • MySQL must be listening on an address reachable from the client.
  • The configured port must be the port the client uses.
  • The host firewall and any upstream firewall must permit that port.
  • The MySQL account must be allowed to authenticate from the client’s host.

Opening a firewall rule cannot compensate for a daemon bound only to loopback, and changing bind-address cannot compensate for a blocked firewall path.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

7. Diagnose “Access denied” as an account problem

An Access denied message means the server was reached and rejected the account, password, host match, or authentication method. It is not evidence that the MySQL service is stopped. Keep service diagnosis and authentication diagnosis separate.

Inspect the account’s User and Host identity and its authentication plugin from an administrative session:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
SELECT User, Host, plugin FROM mysql.user;

MySQL matches both the username and the connecting host. An account created for localhost is not automatically the same account as one created for a remote hostname or address. Check the exact host shown in the error and compare it with the account rows.

Understand auth_socket

Ubuntu installations may use the auth_socket plugin for a local administrative account. With that method, a matching local Unix user can authenticate through the local socket without entering a MySQL password. A password attempt from a different system user, through TCP, or from a remote host can therefore be rejected even when the account exists.

For applications, create a deliberately configured application account with only the required privileges and an appropriate host restriction. Do not weaken root authentication casually just to make a command succeed. Decide whether the account is local-only or remote, choose the authentication method intentionally, and test from the same connection path the application will use.

8. Apply a port or bind-address change safely

Ubuntu’s package example changes the port value in mysqld.cnf, restarts MySQL, and verifies the new listener. Use the same controlled sequence for a port or bind change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Record the current value and the client connection details.
  2. Edit the intended active file or included drop-in, changing one setting only.
  3. Save the file and restart the service: sudo systemctl restart mysql.service.
  4. Check the unit: sudo systemctl status mysql.
  5. Read the new startup messages: sudo journalctl -u mysql.
  6. Verify the actual address and port with sudo ss -ltnp | grep -E 'mysql|3306', adjusting the pattern for a custom port.
  7. Test locally with an explicit TCP host and port, then test remotely only if remote access is required.

If the restart fails, revert the single change using the evidence from the journal and error log. Do not stack a firewall edit, an account change, and a second configuration change on top of an unverified first edit.

9. Recovery playbooks for common symptoms

The service will not start

  1. Run sudo systemctl status mysql.
  2. Read sudo journalctl -u mysql and the active MySQL error log.
  3. Classify the first failure as configuration, permission, endpoint collision, or another explicit operating-system error.
  4. Make the smallest corresponding correction and restart once.
  5. Verify status and the listener after the restart.

ERROR 2002 through localhost

  1. Confirm that MySQL is active and that startup completed.
  2. Check the server and client socket paths.
  3. Force a test to 127.0.0.1 with the configured port.
  4. If TCP works, correct the socket-path mismatch; if TCP fails, return to service and listener diagnostics.

Local connection works, remote connection fails

  1. Run ss and confirm MySQL listens on a reachable address, not only loopback.
  2. Confirm the client is using the configured port.
  3. Check host-firewall and upstream firewall rules.
  4. Inspect the account’s Host value and authentication plugin for the remote source.
  5. Retest and read the exact client error; a timeout suggests a path or firewall issue, while Access denied indicates the server was reached.

The log reports “address already in use”

  1. Identify the owner with sudo ss -ltnp.
  2. Decide whether the existing process should stop or MySQL should use another port.
  3. If changing the port, update every legitimate client and firewall rule that depends on it.
  4. Restart and verify the new listener rather than assuming the edit took effect.

10. Verification checklist after every fix

  • Service: systemctl status mysql reports an active service without a new failure.
  • Evidence: The journal and MySQL error log contain no fresh startup error.
  • Filesystem: The service account can access the confirmed data directory and security controls allow it.
  • Socket: A localhost test uses the same socket path the server creates.
  • TCP: ss shows the expected address and port owned by MySQL.
  • Remote path: The bind address and firewall permit the intended source network.
  • Authentication: The account’s username, host match, and plugin fit the connection path.
  • Persistence: The setting is in the active configuration and survives a service restart.

This sequence distinguishes a failed daemon from a missing socket, a closed network path, and a rejected account. It also keeps potentially disruptive changes—ownership repairs, firewall openings, and authentication edits—until the logs and listener tests show they are necessary.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.