Database connection

Once you have deployed a database server, you can access it via PhpMyAdmin by clicking the [Admin] icon on the Application view or Server Details view. Create your actual database and its tables.

Now you can connect one or more SmartFoxServer instances to the database server by configuring the details in your Zone, via the AdminTool. If you're not familiar with the basics of connecting SFS2X to a database we highly recommend that you review the SmartFoxServer documentation here.

Setting up the connection

Connect to your SmartFoxServer instance via the AdminTool, select the Zone Configurator module and click the Database Manager tab.

database config

Proceed with completing the fields as in the picture:

  • Database driver class: org.mariadb.jdbc.Driver
  • Connection string: jdbc:mariadb://<database-private-ip>:3306/<database-name>
  • Username: root
  • Password: the password you have chosen
  • Test SQL: a valid SQL statement used to check the connection state
  • Exhausted pool action: GROW

Finally hit the Submit button and restart SFS2X for the changes to be activated.

Choosing the MySQL connector

Out of the box we install the MariaDB JDBC connector which is an alternative JDBC driver to the official MySQL connector and which comes with an LGPL license. This allows us to avoid licensing issues when distributing the library with SmartFoxServer 2X.

On the other hand, the official MySQL JDBC Driver comes with a GPL license and can be installed by the customer, if necessary.

If your project requires the official driver you can download the jar file from the link above and upload it to your SmartFoxServer instance via the AdminTool > Extension Manager module under the __lib__/ folder

Upload database driver

Just select the __lib__ folder, hit the [Upload] icon and browse the local disk for the driver's jar file.

When using the MySQL connector the same settings as above can be used with the exception of the following:

  • Database driver class: com.mysql.jdbc.Driver
  • Connection string: jdbc:mysql://<database-private-ip>:3306/<database-name>

Advanced remote administration

As mentioned in the Managing a server document we proivde a web-based UI using PhpMyAdmin to manage your MySQL database(s). However there can be situations where you need a more sophisticated tool, or you'd like a faster interaction with the remote server. In those cases we recommend using the native MySQL Workbench application.

The tool is free and available for all major platforms (Windows, Linux, macOS). Once you have installed it on your machine you will be able to connect to your DB as follows:

mysql workbench
  • Click on the MySQL Connection plus (+) icon
  • Provide the server's IP address and credentials to log in (username is root, password is what you have chosen at setup time).
mysql workbench

If you want to learn more about MySQL Workbench we highly recommend to check the available resources at their product page.