Lineage 2 sites different from other types of sites need to make connections to the database remotely from the server to insert, delete, edit, search, view and etc. data.
Without a proper installation your site will have errors like this:
Failed to connect! #MySQLi
Failed to connect! #PDO-MySQL
Failed to connect! #MySQL
In this guide we will use a template from AtualStudio.com which is the most commercialized and distributed model on the market that serves as a basis for any other sites
- Upload your Lineage 2 website for hosting.
- MySQL/Mariadb Serverinstalled with password on VPS or Dedicated.
Website Hosting Settings
Assuming that you have upload the site to the hosting, the only thing we are going to edit is the config.php file located in /public_html/private/config.php
Each site has its connection variables in different ways but take it as a basis if your site is different:
$server_name: name of your server.
$server_chronicles: version of your server.
$conMethod: MySQL / Mariadb connection method , preferably use mode 2 or 1. Avoid 3 MySQL-PDO is old and has security flaws.
$host = enter the IP of the VPS or Dedicated server.
$dbnm = name of your database (usually l2jdb)
$user = name of the installed MySQL user (usually root)
$pass = MySQL / Mariadb on your server is required to have a password. Do not use easy passwords like root, admin, admin123, pass123, as you understand.
$serverIp = enter the IP of the VPS or Dedicated server, equal to $ host .
$loginPort = leave 2106 is the default login server port.
$gamePort = leave 7777 is the gameserver’s default port.
The work on hosting is over! Save the file and send it to your host.
The settings in the hosting have been completed but we need to give permission to the user of his MySQL / Mariadb and open port 3306 on the windows firewall to connect or any request sent by the site will be denied and the error of Failed Connect! will haunt you again.
As I said at the beginning of the guide you need to have MySQL / Mariadb with a password and an L2J server database installed, ok?
What we need to do is run a simple query that gives all the necessary permissions for the hosting IP to connect to your MySQL / Mariadb .
So download and unzip the file sqlQuery_sites.zip (https://cliente.l2jcenter.com/dl.php?type=d&id=18), it is available in the downloads section of the L2JCenter client area, it is necessary to be registered (free download ).
Open the file and edit the ‘ip_do_site’ and ‘password_mysql’ information , please keep the ” between the two data or you will have syntax problems when running, save the file.
Open your favorite database manager, here we will use the navicat . Select the database that has already been predefined in your website’s config.php and click the right mouse button to choose the option Execute SQL File …
Search for the sqlQuery_sites.sql file and click Start.
Ready! Database configured, will we finish adding a rule allowing connection on port 3306?
For your website to connect in addition to giving permission to the IP of your hosting we will need to create a rule so that it can connect only by its IP, this brings extra security to prevent intruders in some way from gaining access to your bank .
The Windows Lineage 2 Template by default already has this rule enabled for L2JCenter hosting, so this step is only for other templates or if you use another type of hosting.
To access the advanced firewall settings see the image:
There, port 3306 of your firewall is released and you can now test in the browser if the website is working.
Additional safety tip!
It is always recommended that you create scopes on the Windows firewall on specific rules like this one from MySQL because you guarantee that the external connection to this port will only happen between the website host and the server host.
To do this, right-click on the rule you just created and select property.
Click the scope option in the Remote IP Address section and choose the These IP addresses option and click add:
Check the option this IP address or subnet and put that IP you released in the file sqlQuery_sites.sql and click OK.
Ready ! Only the IP of your hosting will have access to the database.
If you want to make remote connections from your computer to the database you can include your external IP as well.