Skip to content

PHP Settings - MySQL and MariaDB Support

Since a lot of PHP projects use MySQL (MariaDB) as database software, ExeOutput for PHP provides you with the ability to include a portable MySQL server (which is MariaDB) along your compiled PHP application. The MySQL server is considered as portable because it doesn't require to be installed as a Windows service in order to work. This behavior is similar to what you can find in "WAMP" distributions, except that we don't use Apache nor PHP software because they are replaced by ExeOutput for PHP.

Tip

Watch our video tutorial about configuring, using and distributing the portable MySQL server with your app.

ExeOutput for PHP will use a portable MySQL server that is provided by the open-source MariaDB project.

Warning

The ExeOutput for PHP's main distribution does not include the portable MariaDB server: use the Web Update utility to download and install the package. Just click the "Check for updates" icon in ExeOutput for PHP to launch the Web Update utility. Then tick "MySQL package for ExeOutput for PHP" and the package will be automatically installed for you.

Once the MySQL package for ExeOutput for PHP is installed, files that will be used for each project are stored in the MySQL\Source\mysql subfolder of the ExeOutput for PHP's main installation folder. Of course, you can update them manually if you want.

Prepare and configure the MySQL Portable Server

First, you must have defined the folder where your application EXE file will be created (Output Path). All files required by the MySQL portable server will be copied into a "MySQL" subfolder.

Note

This subfolder must always be placed in the same folder as the application EXE output file, so you must include this entire folder when you distribute your application or create an installer with Paquet Builder for instance.

When you click this button, you will be prompted for two settings: the root password and the connection port (the TCP/IP port number to use for the connection. The default is 3306).

Then, all files required by the MySQL portable server are copied to the "MySQL" subfolder and the server is started. ExeOutput for PHP will ask you to click OK when the server is ready and listening.

Finally, ExeOutput for PHP shutdowns the server. The latter is now ready for use with your application.

Warning

Do not change the root password yourself. ExeOutput for PHP remembers the root password so that it can shutdown the server when the application closes. If you have to change it, repeat the steps above.

If you want to remember which root password and connection port you used, just click the appropriate links in ExeOutput for PHP named Show configured username and password, and Show configured port.

Create databases and manage them with Adminer

The MySQL server used comes from a vanilla distribution. Except the root password, nothing else is modified: you must then configure settings yourself (thanks to the my.ini configuration file in the "mysql" subfolder).

To manage databases of the portable MySQL server, use a MySQL client: some MySQL clients exist in PHP such as phpmyadmin or Adminer.

We compiled Adminer with ExeOutput for PHP into Adminer EXE so that you can run Adminer EXE without requiring any local PHP installation nor WAMP distribution. Furthermore, to help you administer your portable MySQL server, ExeOutput for PHP can place a temporary copy of Adminer EXE in the same folder as your output EXE file and run it. Thus, Adminer will automatically start the portable MySQL server of your PHP application and let you run SQL commands, manage databases and so on. When you close Adminer EXE, the portable MySQL server is also shut down.

When Adminer EXE is started, enter your credentials:

When Adminer EXE is started, enter your credentials:

Info

If you changed the connection port, enter localhost:[newport] in the server field.

The username is root by default and the password is the root password you defined in a previous step.

Then choose to create a new database, execute SQL command, import data...

Then choose to create a new database, execute SQL command, import data...

Before distributing your PHP application, remove the Adminer EXE tool from the folder or ignore it.

Warning

The ExeOutput for PHP's main distribution does not include the Adminer EXE tool: you must download and install the package yourself thanks to the Web Update utility. Just click the "Check for updates" icon in ExeOutput for PHP to launch the Web Update utility. Then tick "Adminer package for ExeOutput for PHP" and the package will be automatically installed for you.

Associate your PHP application with the MySQL Portable Server

First, be sure to enable the MySQLi PHP extension so that your PHP application can handle MySQL: go to the "PHP Settings -> PHP Extensions" page in ExeOutput for PHP. Then, you can configure your application to automatically start the MySQL server when it is run, and stop it when the application exits: tick Start and stop the MySQL server automatically.

Info

It can take some time before the MySQL server is ready to communicate with your application.

If your application needs to communicate immediately with the data server as soon as it starts, then you may encounter a connection error. That's why you can add a few extra seconds of delay with the following option: Delay to wait for the server to start (in seconds)

If the server cannot be started for some reason, an error is displayed at startup. You can customize the error message thanks to the Localization tab.

Only one instance of the server can be run at a time: we then recommend that you do the same with your application. Go to Security / Global Options and tick Only one instance of the application can be run at a time.

Warning

The PHP application always expects to find the portable server in the "MySQL" subfolder of the application EXE's location.

Remove MySQL server from your application

To remove the portable MySQL server, untick Start and stop the MySQL server automatically and then you can erase the "MySQL" subfolder of the application EXE's location. That's enough.

How to detect MySQL server errors?

The MySQL server stores a lot of information in its log, including any errors that may occur during its execution. To view this log, you just have to click on the link titled "Open server log" in ExeOutput for PHP

ExeOutput's MySQL demo sample

To prove that ExeOutput for PHP can work with MySQL-based apps, we successfully compiled the famous WordPress app into a portable desktop application. The sample comes with full source and a tutorial! Do not hesitate to check it out.

Using Databases in Applications