Configure MySQL for external access

Keywords: MySQL - Windows - Technical issue - Permissions
bnsupport ID: 9f4b3d8c-9d7b-4ba8-0806-1b6958941851
Description:
I got an external Service, who needs to access the mysql-Server.
But when I try to connect to the server, I only get errors. The Hostname for the user of the service ist %, so every IP should’ve access to the database…

Hi @renthner

Thanks for using Bitnami WordPress Multisite!

But when I try to connect to the server, I only get errors.

What are the errors you are experiencing?

The Hostname for the user of the service ist %, so every IP should’ve access to the database…

Have you verified that the two machines you are trying to connect are reachable? Do you have firewall rules blocking traffic to specific ports?

ping YOUR_MACHINE_IP

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Hi @jcarmona

For example I get following errors:

[07:56:55] [Server thread/INFO]: [LogBlock] Enabling LogBlock v1.16.1.1
[07:56:55] [Server thread/INFO]: [LogBlock] Connecting to logblock@jdbc:mysql://192.168.178.152:3306/logblock...
[07:56:55] [Server thread/INFO]: LogBlock-Connection-Pool - Starting...
[07:57:16] [Server thread/ERROR]: LogBlock-Connection-Pool - Exception during pool initialization.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_291]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_291]
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:403) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:335) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2187) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_291]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_291]
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:403) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at de.diddiz.lib.com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[?:?]
        at de.diddiz.lib.com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:353) ~[?:?]
        at de.diddiz.lib.com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) ~[?:?]
        at de.diddiz.lib.com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) ~[?:?]
        at de.diddiz.lib.com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:562) ~[?:?]
        at de.diddiz.lib.com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[?:?]
        at de.diddiz.lib.com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[?:?]
        at de.diddiz.util.MySQLConnectionPool.getConnection(MySQLConnectionPool.java:44) ~[?:?]
        at de.diddiz.LogBlock.LogBlock.getConnection(LogBlock.java:255) ~[?:?]
        at de.diddiz.LogBlock.LogBlock.onEnable(LogBlock.java:78) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:493) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:407) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:555) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:257) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.net.ConnectException: Connection timed out: connect
        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[?:1.8.0_291]
        at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) ~[?:1.8.0_291]
        at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) ~[?:1.8.0_291]
        at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) ~[?:1.8.0_291]
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[?:1.8.0_291]
        at java.net.PlainSocketImpl.connect(Unknown Source) ~[?:1.8.0_291]
        at java.net.SocksSocketImpl.connect(Unknown Source) ~[?:1.8.0_291]
        at java.net.Socket.connect(Unknown Source) ~[?:1.8.0_291]
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:299) ~[spigot-1.16.5.jar:3048-Spigot-a25e8ed-9db9aee]
        ... 32 more
[07:57:17] [Server thread/ERROR]: [LogBlock] Could not connect to the Database! Please check your config! Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

The Servers are both in the same LAN, reachable via ping and I haven’t done any changes to the firewall rules.

Hi @renthner

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

This means that the endpoint was not able to establish any communication with the server. That means that this is not due to incorrect passwords or user account configuration, but to the server itself being unreachable.

The Servers are both in the same LAN, reachable via ping and I haven’t done any changes to the firewall rules.

Okay, so let’s review the configuration of your MySQL DB.

/opt/bitnami/mysql/my.ini

...
# The MySQL server
[mysqld]
# set basedir to your installation path
basedir="C:/Server/Bitnami/mysql"
# set datadir to the location of your data directory
datadir="C:/Server/Bitnami/mysql/data"
port=3306
max_allowed_packet=32M
bind-address=127.0.0.1 <---- The server is binding to the loopback interface!
...

The server is currently set to listen to incoming connections from the same host only. In order to listen to incoming connections from your LAN, set bind-address to the address that has been assigned to the machine running the DB. After that, restart MySQL and try again.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Hi @jcarmona

Thanks for the help. I changed the bind-address and it solved the problem. But at the same time it created two new problems.

  1. My Wordpress (Multisite) cant establish a connection to the Database
  2. I can’t login to phpmyadmin on the machine running the DB.

Here are two screenshots.
https://ibb.co/Lr0CcmZ
https://ibb.co/zNj3Q9m

And I’ve created a new bnsupport ID: 5e7ffbfb-ecd3-8338-1245-1cf96db4b910

Best regards,
Daniel

Hi,

I solved the first problem by adding a new user in phpmyadmin with the credentials I found in wp-config.php and editing the DB_HOST

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'bitnami_wordpress' );

/** MySQL database username */
define( 'DB_USER', 'bn_wordpress' );

/** MySQL database password */
define( 'DB_PASSWORD', '*********' );

/** MySQL hostname */
define( 'DB_HOST', 'IP_ADDRESS:3306' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

Now Wordpress can access the Database with the IP address.
But I still can’t access phpmyadmin with the root-Account from machine running the DB.

Best regards,
Daniel

Okay, now I also solved the second problem by commenting out the line in the my.cnf file:

#bind-address = 127.0.0.1

and restart the mysql server

Thanks for your help @jcarmona

Best regards,
Daniel

Thank you for sharing your solution in the forum!

Glad to see you were able to solve your issue! We are marking the previous answer as “Solution” and this topic as “Closed”.

If you have any other questions, please do not hesitate to let us know. Feel free to create a new topic referencing this one if necessary.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart: