Teamspeak 3 – SQLite3 to MariaDB / MySQL guide

I wanted to do this since I preferred to have my databases in one place, I wanted to move the TS3 server I run to MariaDB. I ran into several struggles, such as converting the database into a format which could be read by MySQL and MariaDB. Since Teamspeak stopped supporting MySQL, you should probably switch to MariaDB.

I found a script that helped me do this, but it didn’t completely fix the problems. So I fixed that.

For this guide, I used Ubuntu 16.04.1 and MariaDB 10.1. You may need to install sqlite3, perl and libmariadb2:

apt-get install sqlite3 perl libmariadb2

Anyway, here is the way to convert your Teamspeak 3 server from SQLite to MariaDB or MySQL. The perl script in this guide can be used for other SQLite conversions.

Exporting and preparing the database:

  1. You need to SSH into the machine and do a dump of the SQLite database, so shut the teamspeak service down:

    systemctl stop teamspeak
    
  2. Create a new database and user for your TS3 server. it is recommended you create one which has a database in its own name which it has full privileges of. phpMyAdmin can help you with this.
  3. Change into the TS3 directory containing ts3server.sqlitedb. For example, my TS3 is located in

    cd /opt/ts3
  4. Backup first, then dump the database from SQLite:

    cp ts3server.sqlitedb ts3server.sqlitedb.bak
    sqlite3 ts3server.sqlitedb .dump > MyDBName.sqlite.sql
  5. Download the script from GitHub:

    wget https://raw.githubusercontent.com/NotoriousPyro/SQLite-to-MariaDB-MySQL-perl-script/master/sqlite-to-mariadb.pl
  6. Now, make it executable run the perl file like so:

    chmod +x sqlite-to-mariadb.pl
    perl sqlite-to-mariadb.pl MyDBName.sqlite.sql > MyDBName.mariadb.sql
  7. You now should have (as long as there were no errors) a MariaDB / MySQL-compatible SQL file! Import it into your MySQL / MariaDB server:

    mysql -u root -p MyDBName < MyDBName.mariadb.sql

FOR MARIADB ONLY:

  1. Change into the sql/updates_and_fixes directory inside your TS3 server folder:

    cd sql/updates_and_fixes
  2. Import these two SQL files to the database you just imported, one after the other has finished:
    mysql -u root -p MyDBName < convert_mysql_to_mariadb.sql
    mysql -u root -p MyDBName < mariadb_fix_latin_utf8.sql

Now, you must set up Teamspeak 3:

  1. Change back into the TS3 directory, open ts3server.ini, and edit the following lines accordingly:

    dbplugin=ts3db_mariadb
    dbpluginparameter=ts3db_mariadb.ini
    dbsqlpath=sql/
    dbsqlcreatepath=create_mariadb/
    dbconnections=10
  2. Now create a new file corresponding to the file name of dbpluginparameter you specified in ts3server.ini and paste into it (I recommend using the first example, and using named sockets instead of port numbers):

    [config]
    username='YOUR USER'
    password='YOUR PASSWORD'
    database='YOUR DATABASE'
    socket='/var/run/mysqld/mysqld.sock'

    or:

    [config]
    server='localhost'
    port='3306'
    username='YOUR USER'
    password='YOUR PASSWORD'
    database='YOUR DATABASE'
  3. Finally, edit your startup script for TS3, so that it reads from ts3server.ini by adding the following as a parameter:

    inifile=/opt/ts3/ts3server.ini

    For example, my /etc/systemd/system/teamspeak.service looks like this:

    [Unit]
    Description=Teamspeak 3
    After=mysqld.service
    
    [Service]
    Type=forking
    User=teamspeak
    Group=teamspeak
    UMask=0027
    Restart=always
    WorkingDirectory=/opt/ts3
    PIDFile=/opt/ts3/ts3server.pid
    ExecStart=/opt/ts3/ts3server_startscript.sh start inifile=/opt/ts3/ts3server.ini
    ExecStop=/opt/ts3/ts3server_startscript.sh stop
    ExecReload=/opt/ts3/ts3server_startscript.sh restart
    
    [Install]
    WantedBy=multi-user.target

And if you’re using JTS3 Server Mod, here’s a daemon you can use:

[Unit]
Description=JTS3 Server Mod daemon
After=teamspeak.service systemd-networkd-wait-online.service

[Service]
Type=forking
User=teamspeak
Group=teamspeak
Umask=0027
RestartSec=10
Restart=always
WorkingDirectory=/opt/ts3/bot
PIDFile=/opt/ts3/bot/jts3servermod.pid
ExecStart=/opt/ts3/bot/jts3servermod_startscript.sh start
ExecStop=/opt/ts3/bot/jts3servermod_startscript.sh stop
ExecReload=/opt/ts3/bot/jts3servermod_startscript.sh restart

[Install]
WantedBy=multi-user.target

2 Comments

  1. Profile photo of Mc$coreMc$core

    With Teamspeak 3.0.13.6 I need

    server='localhost'

    even if I want to connect via Unix socket.

    1. Profile photo of NotoriousPyroNotoriousPyro (Post author)

      Weird, because I have the same server version and it doesn’t require this.

      All I have in my ts3db_mariadb.ini is:

      [config]
      username='ts3server'
      password='****'
      database='ts3server'
      socket='/var/run/mysqld/mysqld.sock'

      The only thing I can think is your server is trying to connect via socket, failing and falling back on connecting via TCP.

      You should have a look at the logs.

Leave a Comment

Skip to toolbar