Update MySQL Errors authored by Ruan's avatar Ruan
## How to test if remote connections can be established
1. Download and install [MySQL Workbench](https://dev.mysql.com/downloads/workbench/) on your own machine
2. Run it, connect to your database using the same details that you'd use with the plugin or the web interface.
Note that you should **not** provide `localhost` or `127.0.0.1` as the address to connect to, if the database is hosted on a separate server and not your local machine.
3. If it can successfully connect to the database but the web interface still can not connect to the database (if your web server and database are hosted on two separate machines), then the problem is on the web host's side and not with the database. Some web hosts don't allow establishing remote connections, only local connections.
4. If it can't connect to the database due to an "access denied" error, then you need to set up [remote access permissions](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#access-denied) on the database side.
5. If it can't connect to the database due to a "connection refused" or "connect timed out" error, then it's probably a [firewall](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-timed-out) or [port binding](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-refused) issue.
---
## How to enable remote connections?
If the database is hosted on the same machine that you're connecting from, connect using address "localhost". Otherwise:
If you have root access for the server running the MySQL database:
- Edit the MySQL configuration (e.g. `/etc/mysql/mariadb.conf.d/50-server.cnf`) and set `bind-address=0.0.0.0`.
- Ensure that `skip-networking` is not set in any of the MySQL configuration files (look in `/etc/mysql/mariadb.conf.d/*` or `/etc/my.cnf.d/*`).
- Restart the MySQL server. (`systemctl restart mysqld`)
If your MySQL database is running in a Docker container, please ensure that you are connecting via the correct IP address.
- The name of your Docker container hosting the MySQL database can be used by other containers as the address for connection purposes.
If you _don't_ have root access, contact your database host to check if they can enable or support remote database connections.
Web hosting plans and game-server-hosting plans generally don't allow remote connections to their MySQL databases for security reasons. Simply having Plesk or cPanel access to the MySQL database does not allow you setup remote connections unless the MySQL server is already configured to do so, in which case you would get an "access denied" error (which you can fix by adding permissions), not a "connection refused" (111) or "connection timed out" (110) error.
## Hosts
Host|Free/Paid|Inbound Remote MySQL|Outbound Connections|Notes
---|---|---|---|---|
000webhost|Free|❌|?|["Remote MySQL connections are disabled ..."](https://www.000webhost.com/website-faq/how-can-i-connect-to-mysql-from-my-computer-27)|
InfinityFree|Free|❌|?|["You cannot connect to a free hosting MySQL database from outside your hosting account."](https://infinityfree.net/support/connecting-to-mysql-from-elsewhere)|
Namecheap|Paid|❌|?||
HostPapa|Paid|❌|?|One user report|
PlanetHoster|Paid|❌|?|Web hosting package only. One user report|
OVH Private SQL|Paid|❌|?|["For a Private SQL server, you can only run ... from an OVHcloud Web Hosting plan"](https://docs.ovh.com/us/en/hosting/connecting-to-database-on-database-server/)|
NameHero|Paid|?|❌|One user report|
Inbound Remote MySQL = whether a database host allows remote clients to connect to its database. If not, it can only be used locally (typically from a website also run by the database host)
Outbound Connections = whether a web host allows you to establish any remote connections to other databases. If not, the web host only allows you to connect to a local database and not a remotely hosted database.
Database hosts that do not give root access, which are not externally accessible due to TCP connect errors like "connection refused" or "connection timed out", and web hosts which give outbound TCP connect errors like "connection refused" or "connection timed out" on a remote database which is otherwise externally accessible will be added to the table above.
---
## Connection errors
### Connection refused:
_Cause: Connection refused (Connection refused)_
_Can't connect to MySQL server on '1.2.3.4' (111 "Connection refused")_
_Can't connect to MySQL server on '1.2.3.4' (115)_
By default, MySQL servers only listen for local connections, meaning that only applications on the same machine can connect to it via `localhost`.
Your MySQL server either needs to be configured to enable remote connections, or there isn't a MySQL server running on the configured address.
See [#How to enable remote connections?](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#how-to-enable-remote-connections)
If you are connecting to `localhost` or `127.0.0.1`:
- If your database is hosted in a separate container on the same machine, it's likely that you'll need to connect using a different IP address than `127.0.0.1`. Containers with different network namespaces are generally assigned IP addresses from a specific local subnet, and your database server should have a static local IP address assigned from that subnet.
- Try switching the host from `localhost` to `127.0.0.1` if this error is from the web interface; this switches the connection method to TCP which is more compatible with containers.
- Try to connect using your server's external IP address instead. If that doesn't work, then your MySQL server has TCP/IP networking disabled due to "skip-networking", or there is no MySQL server running on the same machine.
If you get this error from the web interface using a web host and a remote database (**not the web host's database**):
- Try connecting to your database using a local utility such as [MySQL Workbench](https://dev.mysql.com/downloads/workbench/) in order to ensure that the problem is not on the web host's side.
- If you can successfully connect to the database, it's likely that your web host does not permit outbound remote connections to be established due to web-host sided outbound firewall rules (typically for security reasons).
---
### Connection timed out:
_Cause: Connection timed out: connect_ / _Cause: connect timed out_
_Can't connect to MySQL server on ... (110)_
If the Minecraft server and the MySQL database are running on two separate servers, make sure that port 3306 is allowed in the firewall of the database server, and make sure that the MySQL server is bound to 0.0.0.0 or its external IP (not to localhost)
See [#How to enable remote connections?](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#how-to-enable-remote-connections)
For home-hosted servers, port forwarding is required to connect remotely (port 3306, TCP).
---
### Access denied:
_Cause: Access denied for user 'user'@'your-ip-address' (using password: YES)_
_Cause: Unknown error 1045_
First of all, make sure that the database exists and that you're using the correct database name ("litebans" is the default).
If the MySQL server is not hosted on the same machine as the server running LiteBans, your database most likely does not have remote access permissions configured to allow your server's IP address to connect.
![2020-12-12_09_03_47](uploads/c180c8b06cbe2a1434be5a5cece504a8/2020-12-12_09_03_47.png)
If your MySQL database is hosted on cPanel, look for a "Remote MySQL" section in the panel to configure. The host or IP address you need to allow is quoted by the error message (_Access denied for user 'user'@'your-ip-address'_)
Alternatively, you can use phpMyAdmin. Log into phpMyAdmin, click on your database, click the "User accounts" tab, and click "Add user account".
![2020-12-12_09_44_58](uploads/317cf3982a8f14eada9080e8e04b6533/2020-12-12_09_44_58.png)
Otherwise, if you have access to run database queries, try running these queries:
```
CREATE USER '<username>'@'%' IDENTIFIED BY '<password>';
GRANT ALL ON <database>.* TO '<username>'@'%';
```
Replacing `<database>` with your database name (make sure it exists), `<username>` and `<password>` are yours to decide.
If you don't have cPanel access nor access to run database queries, contact your database host.
Also see:
- https://docs.phpmyadmin.net/en/latest/privileges.html
- https://mariadb.com/kb/en/library/configuring-mariadb-for-remote-client-access/#granting-user-connections-from-remote-hosts
- https://www.hostinger.com/how-to/how-to-set-up-a-remote-mysql-access
---
### No route to host:
_Cause: No route to host (Host unreachable)_
Port binding / firewall issue, similar to [Connection timed out](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-timed-out). Ensure that port 3306 is not blocked and that port forwarding is configured, if applicable.
---
### CLIENT_PLUGIN_AUTH is required
This is caused by an outdated MySQL server.
Workaround 1: Downgrade the MySQL driver.
In config.yml, modify the `drivers` section. It should look like this after modification:
```
drivers:
- version:8
- 'mysql:com.mysql.jdbc.Driver:https://repo1.maven.org/maven2/mysql/mysql-connector-java/{}/mysql-connector-java-{}.jar:5.1.38:b95bf9fe25cb5428f378a62fc842e177ca004b4ae1f9054968b2a396dcc1ec22'
- 'pgsql:org.postgresql.Driver:https://repo1.maven.org/maven2/org/postgresql/postgresql/{}/postgresql-{}.jar:42.4.0:fe25b9c0a2c59458504ec88862853df522ee87f8a02564835d537c29ae4cb125'
- 'mariadb:org.mariadb.jdbc.Driver:https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/{}/mariadb-java-client-{}.jar:3.1.2:aaec1ad348d030a65b25c93c65cdaf472bf8b4b6b314b965e5ba13aec81bc622'
- 'sqlite:org.sqlite.JDBC:https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/{}/sqlite-jdbc-{}.jar:3.8.11.1:58ab29176a24a85a0c76177561257a986c4865e45730b79882c688846371d341'
- 'h2:org.h2.Driver:https://repo1.maven.org/maven2/com/h2database/h2/{}/h2-{}.jar:1.4.197:37f5216e14af2772930dff9b8734353f0a80e89ba3f33e065441de6537c5e842'
```
1) Ensure that 'version' is set to the latest (currently `version:8`)
2) Change "com.mysql.cj.jdbc.Driver" to "com.mysql.jdbc.Driver"
3) Change mysql driver version from "8.0.29" to "5.1.38"
4) Change the SHA-256 checksum to `b95bf9fe25cb5428f378a62fc842e177ca004b4ae1f9054968b2a396dcc1ec22`
Workaround 2: Set `driver: MariaDB` instead of `driver: MySQL` in config.yml.
([MariaDB](https://mariadb.org/) is a fork of MySQL which offers, among other things, being a drop-in replacement for MySQL, and better performance)
---
### Public Key Retrieval is not allowed
### RSA public key is not available client side (option serverRsaPublicKeyFile not set)
Enabling SSL should fix this. Change `useSSL=false` to `useSSL=true` in config.yml (set `options: 'useSSL=true&serverTimezone=UTC'`)
If that doesn't work, try this: `options: 'useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC'`
---
### Unable to load authentication plugin 'caching_sha2_password':
This error is caused by the new, default MySQL 8 authentication plugin, `caching_sha2_password`.
This plugin requires SSL to be enabled. Set `options: 'useSSL=true'` in config.yml to fix this error.
---
### The server requested authentication method unknown to the client
This error is specific to MySQL 8 servers. MariaDB is unaffected.
To fix this, you have to log into the database and run a query as root:
```
ALTER USER 'user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
```
Replacing 'user' and 'password' with your MySQL username and password, and '%' with the hostname that your user is permitted to connect to (leave it set to '%' if your user is allowed to connect from all hosts)
If this doesn't work, switching to MariaDB is recommended, not only as a solution, but also for better performance.
---
### MySQL server has gone away
_Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost._
This error indicates that a "connection reset" situation occurred: the connection was successfully established, but then something caused the connection to be terminated before any response could be read from the server.
The cause of this could be an authentication error (see [Access denied](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#access-denied)), or a firewall related error (see [Connection timed out](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-timed-out)).
### Unknown system variable 'transaction_isolation'
This error can occur if you try to use the MySQL driver with a MariaDB database server.
To fix it, set `driver: MariaDB` instead of `driver: MySQL` in `config.yml`, and reload LiteBans.
---
## Runtime errors
### Too many connections:
_Error: 1040-08004: Too many connections_
Your MySQL server's connection limit ([max_connections](https://mariadb.com/kb/en/server-system-variables/#max_connections)) needs to be raised in order to support the active number of database connections.
By default, each individual instance of LiteBans can create 10 concurrent database connections under full load, and 1-3 connections under light load. Therefore, if you have 5 server instances, you would need to increase `max_connections` by 50 to ensure stable operation. If you have many plugins using the database, and many instances of LiteBans, you should consider setting a very high value of `max_connections` (256, 512, 1024).
### SocketTimeoutException: Read timed out:
Socket timeouts are generated when the database server stops responding to requests for a given period of time. There are many possible causes for this type of error:
- Your database server, or the machine running it, may have been temporarily shut down for maintenance purposes, or is in the process of rebooting.
- Your database server may be resource-starved (CPU or disk I/O bound), either due to a background process (such as a backup task) or due to an intensive database query from any source.
- There could be a hardware failure at any point between the client and the server causing a disrupted network connection (packet loss) or other type of fault. For example, a router may be rebooting once or twice per day under specific loads due to age-related electrical faults. To rule out network failure, one must run a long-term ping test from the client to the server or vice versa - the amount of packets lost should ideally be zero.
- There could be a firewall (on the database server side) that is configured to block connections via timeout when a single IP address makes too many connection attempts within a given time period, or reaches a connection limit.
**Why does LiteBans give socket timeout errors while other plugins do not?** LiteBans sets an attribute called a socket timeout (Not to be confused with "connection timeout", which specifically refers to the timeout used while attempting to create a new connection.) - for connection pools like HikariCP, the default socket timeout is infinite unless specified via the `socketTimeout` connection property. The socket timeout defines the maximum amount of time that will be spent waiting for an active query to finish and receive a response from the database server. Clients which have an infinite socket timeout will simply hang indefinitely while awaiting a response, which will produce no visible error messages while tasks have all frozen up internally.
For LiteBans specifically, the socket timeout is set to the same value as the connection timeout - 25 seconds by default. Other plugins typically leave it unset or set a different value.
### Connection ... marked as broken because of SQLSTATE(08S01) ... Read timed out
### No operations allowed after connection closed:
If this happened only once: Your MySQL server was probably restarted.
If this happens constantly or intermittently:
- Try setting `keepalive: 30 seconds` in config.yml. If this helps, set it to a higher value later (e.g. `keepalive: 60 seconds`) to reduce the CPU usage of sending constant keepalive requests to the database server.
- Try reducing the `idle_timeout` and/or `max_lifetime` options in config.yml to 30 seconds.
- If the above options don't work, a firewall may be rate limiting connections. Other plugins using the same database will probably show the same error.
### SQLSyntaxErrorException: Table 'litebans.litebans_history' doesn't exist / Unknown error 1146
This error indicates that LiteBans was unable to create its tables on startup, probably due to a lack of database permissions.
If you want to see the true error, run `/litebans reload` and check the console.
### InnoDB: Running in read-only mode:
If the database has been moved to a different server recently, then it wasn't moved properly (possibly incorrect file permissions).
The MySQL server's system logs will likely indicate the underlying cause of this. Disk errors are a likely cause.
In order to fix the problem, you'll have to restore everything from backup, or copy all of the old read-only corrupted data into new tables, in an attempt to recover most of it (some data may be lost if you do this).
https://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
If the database is on a broken storage device, then it will have to be replaced first. (Some SSDs go into read-only mode when they hit their write-cycle limit)
### Connection pool exhaustion detected:
This generally indicates that the Minecraft server or the database server is overloaded and doesn't have enough CPU power available to serve the active requests.
LiteBans is multithreaded and can use a configurable amount of CPU cores - the option `max_connections` decides the upper limit (10 by default). If the database server has free CPU available, it is recommended to increase `max_connections` to `((physical CPU cores)*2)+2`, while `+2` can be increased up to `+10` depending on network and disk latency (higher latency = more connections).
See [About Pool Sizing](https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing). The vast majority of LiteBans queries are short-running queries.
## Other issues
### All players disconnected from the server, then LiteBans logged a database connection error.
_Connection ... marked as broken because of SQLSTATE(08), ErrorCode(0)_ or _Connection timed out_
LiteBans will *not* eject all players from the server because of a database connection error. You can try this yourself; join the server with no plugins installed except LiteBans, stop the MySQL server for a short while, and you will remain online. Therefore, LiteBans did not cause your server to "crash" nor did it kick online players for no apparent reason. Please don't assume this is the case.
What most likely happened was:
* Your server/host had a network outage.
* Your server/host received a DDoS attack, which caused all plugins to disconnect from the database because your server was unable to send or receive packets.
* Your server ran out of memory, causing all plugins to throw errors. (GC pauses exceeding 30 seconds cause connection timeouts)
## How to test if remote connections can be established
1. Download and install [MySQL Workbench](https://dev.mysql.com/downloads/workbench/) on your own machine
2. Run it, connect to your database using the same details that you'd use with the plugin or the web interface.
Note that you should **not** provide `localhost` or `127.0.0.1` as the address to connect to, if the database is hosted on a separate server and not your local machine.
3. If it can successfully connect to the database but the web interface still can not connect to the database (if your web server and database are hosted on two separate machines), then the problem is on the web host's side and not with the database. Some web hosts don't allow establishing remote connections, only local connections.
4. If it can't connect to the database due to an "access denied" error, then you need to set up [remote access permissions](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#access-denied) on the database side.
5. If it can't connect to the database due to a "connection refused" or "connect timed out" error, then it's probably a [firewall](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-timed-out) or [port binding](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-refused) issue.
---
## How to enable remote connections?
If the database is hosted on the same machine that you're connecting from, connect using address "localhost". Otherwise:
If you have root access for the server running the MySQL database:
- Edit the MySQL configuration (e.g. `/etc/mysql/mariadb.conf.d/50-server.cnf`) and set `bind-address=0.0.0.0`.
- Ensure that `skip-networking` is not set in any of the MySQL configuration files (look in `/etc/mysql/mariadb.conf.d/*` or `/etc/my.cnf.d/*`).
- Restart the MySQL server. (`systemctl restart mysqld`)
If your MySQL database is running in a Docker container, please ensure that you are connecting via the correct IP address.
- The name of your Docker container hosting the MySQL database can be used by other containers as the address for connection purposes.
If you _don't_ have root access, contact your database host to check if they can enable or support remote database connections.
Web hosting plans and game-server-hosting plans generally don't allow remote connections to their MySQL databases for security reasons. Simply having Plesk or cPanel access to the MySQL database does not allow you setup remote connections unless the MySQL server is already configured to do so, in which case you would get an "access denied" error (which you can fix by adding permissions), not a "connection refused" (111) or "connection timed out" (110) error.
## Hosts
Host|Free/Paid|Inbound Remote MySQL|Outbound Connections|Notes
---|---|---|---|---|
000webhost|Free|❌|?|["Remote MySQL connections are disabled ..."](https://www.000webhost.com/website-faq/how-can-i-connect-to-mysql-from-my-computer-27)|
InfinityFree|Free|❌|?|["You cannot connect to a free hosting MySQL database from outside your hosting account."](https://infinityfree.net/support/connecting-to-mysql-from-elsewhere)|
Namecheap|Paid|❌|?||
HostPapa|Paid|❌|?|One user report|
PlanetHoster|Paid|❌|?|Web hosting package only. One user report|
OVH Private SQL|Paid|❌|?|["For a Private SQL server, you can only run ... from an OVHcloud Web Hosting plan"](https://docs.ovh.com/us/en/hosting/connecting-to-database-on-database-server/)|
NameHero|Paid|?|❌|One user report|
Inbound Remote MySQL = whether a database host allows remote clients to connect to its database. If not, it can only be used locally (typically from a website also run by the database host)
Outbound Connections = whether a web host allows you to establish any remote connections to other databases. If not, the web host only allows you to connect to a local database and not a remotely hosted database.
Database hosts that do not give root access, which are not externally accessible due to TCP connect errors like "connection refused" or "connection timed out", and web hosts which give outbound TCP connect errors like "connection refused" or "connection timed out" on a remote database which is otherwise externally accessible will be added to the table above.
---
## Connection errors
### Connection refused:
_Cause: Connection refused (Connection refused)_
_Can't connect to MySQL server on '1.2.3.4' (111 "Connection refused")_
_Can't connect to MySQL server on '1.2.3.4' (115)_
By default, MySQL servers only listen for local connections, meaning that only applications on the same machine can connect to it via `localhost`.
Your MySQL server either needs to be configured to enable remote connections, or there isn't a MySQL server running on the configured address.
See [#How to enable remote connections?](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#how-to-enable-remote-connections)
If you are connecting to `localhost` or `127.0.0.1`:
- If your database is hosted in a separate container on the same machine, it's likely that you'll need to connect using a different IP address than `127.0.0.1`. Containers with different network namespaces are generally assigned IP addresses from a specific local subnet, and your database server should have a static local IP address assigned from that subnet.
- Try switching the host from `localhost` to `127.0.0.1` if this error is from the web interface; this switches the connection method to TCP which is more compatible with containers.
- Try to connect using your server's external IP address instead. If that doesn't work, then your MySQL server has TCP/IP networking disabled due to "skip-networking", or there is no MySQL server running on the same machine.
If you get this error from the web interface using a web host and a remote database (**not the web host's database**):
- Try connecting to your database using a local utility such as [MySQL Workbench](https://dev.mysql.com/downloads/workbench/) in order to ensure that the problem is not on the web host's side.
- If you can successfully connect to the database, it's likely that your web host does not permit outbound remote connections to be established due to web-host sided outbound firewall rules (typically for security reasons).
---
### Connection timed out:
_Cause: Connection timed out: connect_ / _Cause: connect timed out_
_Can't connect to MySQL server on ... (110)_
If the Minecraft server and the MySQL database are running on two separate servers, make sure that port 3306 is allowed in the firewall of the database server, and make sure that the MySQL server is bound to 0.0.0.0 or its external IP (not to localhost)
See [#How to enable remote connections?](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#how-to-enable-remote-connections)
For home-hosted servers, port forwarding is required to connect remotely (port 3306, TCP).
---
### Access denied:
_Cause: Access denied for user 'user'@'your-ip-address' (using password: YES)_
_Cause: Unknown error 1045_
First of all, make sure that the database exists and that you're using the correct database name ("litebans" is the default).
If the MySQL server is not hosted on the same machine as the server running LiteBans, your database most likely does not have remote access permissions configured to allow your server's IP address to connect.
![2020-12-12_09_03_47](uploads/c180c8b06cbe2a1434be5a5cece504a8/2020-12-12_09_03_47.png)
If your MySQL database is hosted on cPanel, look for a "Remote MySQL" section in the panel to configure. The host or IP address you need to allow is quoted by the error message (_Access denied for user 'user'@'your-ip-address'_)
Alternatively, you can use phpMyAdmin. Log into phpMyAdmin, click on your database, click the "User accounts" tab, and click "Add user account".
![2020-12-12_09_44_58](uploads/317cf3982a8f14eada9080e8e04b6533/2020-12-12_09_44_58.png)
Otherwise, if you have access to run database queries, try running these queries:
```
CREATE USER '<username>'@'%' IDENTIFIED BY '<password>';
GRANT ALL ON <database>.* TO '<username>'@'%';
```
Replacing `<database>` with your database name (make sure it exists), `<username>` and `<password>` are yours to decide.
If you don't have cPanel access nor access to run database queries, contact your database host.
Also see:
- https://docs.phpmyadmin.net/en/latest/privileges.html
- https://mariadb.com/kb/en/library/configuring-mariadb-for-remote-client-access/#granting-user-connections-from-remote-hosts
- https://www.hostinger.com/how-to/how-to-set-up-a-remote-mysql-access
---
### No route to host:
_Cause: No route to host (Host unreachable)_
Port binding / firewall issue, similar to [Connection timed out](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-timed-out). Ensure that port 3306 is not blocked and that port forwarding is configured, if applicable.
---
### CLIENT_PLUGIN_AUTH is required
This is caused by an outdated MySQL server.
Workaround 1: Downgrade the MySQL driver.
In config.yml, modify the `drivers` section. It should look like this after modification:
```
drivers:
- version:8
- 'mysql:com.mysql.jdbc.Driver:https://repo1.maven.org/maven2/mysql/mysql-connector-java/{}/mysql-connector-java-{}.jar:5.1.38:b95bf9fe25cb5428f378a62fc842e177ca004b4ae1f9054968b2a396dcc1ec22'
- 'pgsql:org.postgresql.Driver:https://repo1.maven.org/maven2/org/postgresql/postgresql/{}/postgresql-{}.jar:42.4.0:fe25b9c0a2c59458504ec88862853df522ee87f8a02564835d537c29ae4cb125'
- 'mariadb:org.mariadb.jdbc.Driver:https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/{}/mariadb-java-client-{}.jar:3.1.2:aaec1ad348d030a65b25c93c65cdaf472bf8b4b6b314b965e5ba13aec81bc622'
- 'sqlite:org.sqlite.JDBC:https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/{}/sqlite-jdbc-{}.jar:3.8.11.1:58ab29176a24a85a0c76177561257a986c4865e45730b79882c688846371d341'
- 'h2:org.h2.Driver:https://repo1.maven.org/maven2/com/h2database/h2/{}/h2-{}.jar:1.4.197:37f5216e14af2772930dff9b8734353f0a80e89ba3f33e065441de6537c5e842'
```
1) Ensure that 'version' is set to the latest (currently `version:8`)
2) Change "com.mysql.cj.jdbc.Driver" to "com.mysql.jdbc.Driver"
3) Change mysql driver version from "8.0.29" to "5.1.38"
4) Change the SHA-256 checksum to `b95bf9fe25cb5428f378a62fc842e177ca004b4ae1f9054968b2a396dcc1ec22`
Workaround 2: Set `driver: MariaDB` instead of `driver: MySQL` in config.yml.
([MariaDB](https://mariadb.org/) is a fork of MySQL which offers, among other things, being a drop-in replacement for MySQL, and better performance)
---
### Public Key Retrieval is not allowed
### RSA public key is not available client side (option serverRsaPublicKeyFile not set)
Enabling SSL should fix this. Change `useSSL=false` to `useSSL=true` in config.yml (set `options: 'useSSL=true&serverTimezone=UTC'`)
If that doesn't work, try this: `options: 'useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC'`
---
### Unable to load authentication plugin 'caching_sha2_password':
This error is caused by the new, default MySQL 8 authentication plugin, `caching_sha2_password`.
This plugin requires SSL to be enabled. Set `options: 'useSSL=true'` in config.yml to fix this error.
---
### The server requested authentication method unknown to the client
This error is specific to MySQL 8 servers. MariaDB is unaffected.
To fix this, you have to log into the database and run a query as root:
```
ALTER USER 'user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
```
Replacing 'user' and 'password' with your MySQL username and password, and '%' with the hostname that your user is permitted to connect to (leave it set to '%' if your user is allowed to connect from all hosts)
If this doesn't work, switching to MariaDB is recommended, not only as a solution, but also for better performance.
---
### MySQL server has gone away
_Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost._
This error indicates that a "connection reset" situation occurred: the connection was successfully established, but then something caused the connection to be terminated before any response could be read from the server.
The cause of this could be an authentication error (see [Access denied](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#access-denied)), or a firewall related error (see [Connection timed out](https://gitlab.com/ruany/LiteBans/-/wikis/MySQL-Errors#connection-timed-out)).
### Unknown system variable 'transaction_isolation'
This error can occur if you try to use the MySQL driver with a MariaDB database server.
To fix it, set `driver: MariaDB` instead of `driver: MySQL` in `config.yml`, and reload LiteBans.
---
## Runtime errors
### Too many connections:
_Error: 1040-08004: Too many connections_
Your MySQL server's connection limit ([max_connections](https://mariadb.com/kb/en/server-system-variables/#max_connections)) needs to be raised in order to support the active number of database connections.
By default, each individual instance of LiteBans can create 10 concurrent database connections under full load, and 1-3 connections under light load. Therefore, if you have 5 server instances, you would need to increase `max_connections` by 50 to ensure stable operation. If you have many plugins using the database, and many instances of LiteBans, you should consider setting a very high value of `max_connections` (256, 512, 1024).
### SocketTimeoutException: Read timed out:
Socket timeouts are generated when the database server stops responding to requests for a given period of time. There are many possible causes for this type of error:
- Your database server may not have NTP (network time synchronization) set up correctly. If it is hosted in a virtual environment without NTP, the host could take a long time to update the system time of all guests, which would result in system time jumping backwards or forwards by 20-60 seconds on a regular basis, which can cause connection timeouts and various, otherwise undetected negative side effects.
- Your database server, or the machine running it, may have been temporarily shut down for maintenance purposes, or is in the process of rebooting.
- Your database server may be resource-starved (CPU or disk I/O bound), either due to a background process (such as a backup task) or due to an intensive database query from any source.
- There could be a hardware failure at any point between the client and the server causing a disrupted network connection (packet loss) or other type of fault. For example, a router may be rebooting once or twice per day under specific loads due to age-related electrical faults. To rule out network failure, one must run a long-term ping test from the client to the server or vice versa - the amount of packets lost should ideally be zero.
- There could be a firewall (on the database server side) that is configured to block connections via timeout when a single IP address makes too many connection attempts within a given time period, or reaches a connection limit.
**Why does LiteBans give socket timeout errors while other plugins do not?** LiteBans sets an attribute called a socket timeout (Not to be confused with "connection timeout", which specifically refers to the timeout used while attempting to create a new connection.) - for connection pools like HikariCP, the default socket timeout is infinite unless specified via the `socketTimeout` connection property. The socket timeout defines the maximum amount of time that will be spent waiting for an active query to finish and receive a response from the database server. Clients which have an infinite socket timeout will simply hang indefinitely while awaiting a response, which will produce no visible error messages while tasks have all frozen up internally.
For LiteBans specifically, the socket timeout is set to the same value as the connection timeout - 25 seconds by default. Other plugins typically leave it unset or set a different value.
### Connection ... marked as broken because of SQLSTATE(08S01) ... Read timed out
### No operations allowed after connection closed:
If this happened only once: Your MySQL server was probably restarted.
If this happens constantly or intermittently:
- Try setting `keepalive: 30 seconds` in config.yml. If this helps, set it to a higher value later (e.g. `keepalive: 60 seconds`) to reduce the CPU usage of sending constant keepalive requests to the database server.
- Try reducing the `idle_timeout` and/or `max_lifetime` options in config.yml to 30 seconds.
- If the above options don't work, a firewall may be rate limiting connections. Other plugins using the same database will probably show the same error.
### SQLSyntaxErrorException: Table 'litebans.litebans_history' doesn't exist / Unknown error 1146
This error indicates that LiteBans was unable to create its tables on startup, probably due to a lack of database permissions.
If you want to see the true error, run `/litebans reload` and check the console.
### InnoDB: Running in read-only mode:
If the database has been moved to a different server recently, then it wasn't moved properly (possibly incorrect file permissions).
The MySQL server's system logs will likely indicate the underlying cause of this. Disk errors are a likely cause.
In order to fix the problem, you'll have to restore everything from backup, or copy all of the old read-only corrupted data into new tables, in an attempt to recover most of it (some data may be lost if you do this).
https://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
If the database is on a broken storage device, then it will have to be replaced first. (Some SSDs go into read-only mode when they hit their write-cycle limit)
### Connection pool exhaustion detected:
This generally indicates that the Minecraft server or the database server is overloaded and doesn't have enough CPU power available to serve the active requests.
LiteBans is multithreaded and can use a configurable amount of CPU cores - the option `max_connections` decides the upper limit (10 by default). If the database server has free CPU available, it is recommended to increase `max_connections` to `((physical CPU cores)*2)+2`, while `+2` can be increased up to `+10` depending on network and disk latency (higher latency = more connections).
See [About Pool Sizing](https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing). The vast majority of LiteBans queries are short-running queries.
## Other issues
### All players disconnected from the server, then LiteBans logged a database connection error.
_Connection ... marked as broken because of SQLSTATE(08), ErrorCode(0)_ or _Connection timed out_
LiteBans will *not* eject all players from the server because of a database connection error. You can try this yourself; join the server with no plugins installed except LiteBans, stop the MySQL server for a short while, and you will remain online. Therefore, LiteBans did not cause your server to "crash" nor did it kick online players for no apparent reason. Please don't assume this is the case.
What most likely happened was:
* Your server/host had a network outage.
* Your server/host received a DDoS attack, which caused all plugins to disconnect from the database because your server was unable to send or receive packets.
* Your server ran out of memory, causing all plugins to throw errors. (GC pauses exceeding 30 seconds cause connection timeouts)
* Your database server host had a network outage which caused _another_ plugin to crash the server.
\ No newline at end of file