Error
Error Code:
3168
MySQL Error 3168: Server Unavailable
Description
This error indicates that a MySQL client application cannot establish a connection with the MySQL server. It typically means the server is not running, is inaccessible over the network, or is not responding to connection requests, preventing any database operations.
Error Message
Server isn't available
Known Causes
3 known causesMySQL Server Not Running
The MySQL service or daemon on the host machine is stopped, preventing any incoming client connections.
Network Connectivity Blocked
A network firewall, incorrect routing, or general network issue is preventing the client from reaching the MySQL server's configured port.
Incorrect Connection Parameters
The client application is attempting to connect to an incorrect hostname, IP address, or port number for the MySQL server instance.
Solutions
4 solutions available1. Verify MySQL Server Process is Running easy
Checks if the MySQL server daemon is active and restarts it if necessary.
1
Check the status of the MySQL service.
sudo systemctl status mysql
2
If the service is not active, start it.
sudo systemctl start mysql
3
If the service was running but still unavailable, try restarting it.
sudo systemctl restart mysql
4
After starting or restarting, check the status again to confirm it's active.
sudo systemctl status mysql
2. Check MySQL Server Configuration for Binding Address medium
Ensures MySQL is configured to listen on an accessible network interface.
1
Locate your MySQL configuration file. Common locations include `/etc/mysql/my.cnf`, `/etc/my.cnf`, or `/etc/mysql/mysql.conf.d/mysqld.cnf`.
2
Open the configuration file with a text editor.
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
3
Look for the `bind-address` directive within the `[mysqld]` section. If it's set to `127.0.0.1` or `localhost`, MySQL will only accept connections from the local machine. To allow remote connections, change it to `0.0.0.0` (to listen on all interfaces) or the specific IP address of the server.
[mysqld]
bind-address = 0.0.0.0
4
Save the changes and exit the editor.
5
Restart the MySQL service for the changes to take effect.
sudo systemctl restart mysql
3. Examine MySQL Error Logs for Specific Issues medium
Investigates detailed error messages in MySQL logs to pinpoint the root cause.
1
Locate your MySQL error log file. Common locations include `/var/log/mysql/error.log` or `/var/log/mysqld.log`.
2
View the end of the error log file for recent entries.
sudo tail /var/log/mysql/error.log
3
Look for any error messages that indicate specific problems, such as disk space issues, corrupted tables, permission errors, or configuration problems.
4
Based on the error messages found, take appropriate actions. For example, if you see 'No space left on device', you need to free up disk space. If you see permission errors, you need to adjust file/directory permissions.
5
After addressing any identified issues, restart the MySQL service.
sudo systemctl restart mysql
4. Check Firewall Rules medium
Ensures that network firewalls are not blocking connections to the MySQL port.
1
Identify the port MySQL is running on. The default is 3306.
2
Check your server's firewall rules. For `ufw` (Uncomplicated Firewall):
sudo ufw status
3
If port 3306 is not allowed, allow it. Replace `3306` if your MySQL is on a different port.
sudo ufw allow 3306/tcp
4
If using `firewalld`:
sudo firewall-cmd --list-all
5
Add the MySQL port if it's missing.
sudo firewall-cmd --permanent --add-port=3306/tcp
sudo firewall-cmd --reload
6
If you are connecting from a remote machine, ensure that the firewall on that machine and any intermediate network devices also allow connections to port 3306 on the MySQL server.