Chatilo
USDPrices shown in US dollars Sign in Start free trial
For platform admins

Move from SQLite to MySQL

What Chatilo supports when you started on SQLite and want MySQL or MariaDB, and an honest outline of moving your data by hand.

Last updated

On this page
  1. Which database to use
  2. What is and is not supported
  3. Route 1: start fresh on MySQL (supported)
  4. Route 2: move the data by hand (not tested)
  5. Common problems

The installer offers two databases: MySQL / MariaDB and SQLite (testing only). If you chose SQLite to try the product and now want to go live, read this first.

Which database to use

Use MySQL or MariaDB for a live site. The installer says so itself: SQLite "stores everything in one file" and is there "to try Chatilo, not for live customers".

SQLite keeps all data in one file, storage/chatilo.sqlite, and only one process can write to it at a time. On a live site the website, incoming webhooks and the background worker all write at once and would wait on each other. MySQL and MariaDB are built for that.

What is and is not supported

  • There is no built-in converter. Chatilo has no tool or screen that copies data from SQLite to MySQL.
  • You cannot change the database type from the admin panel. The database is chosen in the installer and stored in config/config.php.
  • Chatilo can create its tables on an empty MySQL database at any time, because it applies its own database updates. Moving the data is up to you.

So there are two routes.

Route 1: start fresh on MySQL (supported)

This is the right route if the SQLite install only holds test data.

  1. Create an empty MySQL or MariaDB database and a user for it.
  2. Keep a copy of config/config.php and storage/chatilo.sqlite somewhere safe, in case you want to look something up later.
  3. Delete storage/installed.lock and config/config.php.
  4. Open the site. The installer starts. Choose MySQL / MariaDB and complete it. See Install on CloudPanel.
  5. Enter your platform settings, plans and gateway keys again.

The new install has a new app key and an empty database. Nothing from the SQLite install carries over.

Route 2: move the data by hand (not tested)

The idea is to let Chatilo create the tables on MySQL, then copy the rows across yourself.

  1. Turn on Maintenance mode on the System page and remove the cron job, so nothing writes to the database while you work.
  2. Back up storage/chatilo.sqlite and config/config.php. See Back up and restore.
  3. Create an empty MySQL or MariaDB database.
  4. In config/config.php, replace the db block with the MySQL details. Leave the app block, and especially its key, exactly as it is: the key is what decrypts the tokens stored in your data.
  5. Over SSH, from the application folder, run php bin/migrate.php. It creates every table on the MySQL database and adds the starter plans and default settings.
  6. Empty the tables that step 5 filled with starter data (plans and settings), so your own rows can go in with their original IDs. Leave the migrations table alone.
  7. Copy the rows of every other table from the SQLite file into the MySQL database with your own script or tool, keeping every ID unchanged.
  8. Open the site, sign in and check workspaces, conversations, payments and invoices. Check that a connected WhatsApp number still shows as connected, which proves the app key still matches.
  9. Add the cron job back and turn Maintenance mode off.

The db block for MySQL looks like this:

'db' => array (
  'driver' => 'mysql',
  'host' => '127.0.0.1',
  'port' => 3306,
  'name' => 'DB_NAME',
  'user' => 'DB_USER',
  'pass' => 'DB_PASSWORD',
),

Things that can go wrong in step 7:

  • Generic SQLite dump files do not import into MySQL as they are; the two databases use different SQL for table definitions. Copy data only, not table definitions.
  • Text with emoji needs the utf8mb4 character set on the connection you import with.
  • Dates are saved on SQLite as text in the form YYYY-MM-DD HH:MM:SS, in UTC. MySQL's date columns take that form as it is.

If you are not confident doing this, use Route 1 and ask customers to connect their numbers again.

Common problems

"Database is already up to date." but the MySQL database is empty

php bin/migrate.php used the old db block. Check that you saved config/config.php with the MySQL details.

After the move, numbers show as disconnected and saved keys are empty

The key in config/config.php changed, or you completed the installer again. Put the original config/config.php back and only change its db block.

"Something broke on our side" after editing config.php

The file has a PHP syntax error or wrong database details. Look in storage/logs/php-error.log and the newest storage/logs/app-…log.

Cookies on this site

We use the cookies needed to run the site and keep you signed in. With your OK we also remember choices you make here, such as the currency for prices. We don’t use advertising or tracking cookies. Cookie policy