Skip to content

Teamspeak 3 with MySQL on CentOS 6.x (3.0.11.1 Onwards)

By default Teamspeak 3 uses a SQLite database, most people tend to use this however for those of us that prefer MySQL there is a way to change it.

Follow this small tutorial to create a Teamspeak 3 Server on CentOS 6.x using a MySQL Database!

First we need to install or upgrade MySQL:
Install:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum --enablerepo=remi,remi-test list mysql mysql-server
yum --enablerepo=remi,remi-test install mysql mysql-server

Upgrade:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum --enablerepo=remi,remi-test list mysql mysql-server
yum --enablerepo=remi,remi-test update mysql mysql-server
mysql_upgrade -u root -p

Now we need to create a new user on our server, this user will be used for the installation and running of teamspeak. For security reasons this user will not have sudo etc.

useradd ts3user
passwd ts3user

We are now in a position where we can configure MySQL with a Database and User for Teamspeak

service mysqld start
chkconfig mysqld on
mysql_secure_installation

mysql -uroot -p

create database ts3db;
grant all on ts3db.* to 'ts3user'@'127.0.0.1' identified by 'ts3password';
flush privileges;

Once the MySQL Database is set-up along with a user we will create an init script for Teamspeak so that we can start the server as a service, create the script: vi /etc/init.d/teamspeak

#!/bin/bash
# /etc/init.d/teamspeak

### BEGIN INIT INFO
# Provides: teamspeak
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Teamspeak 3 Server
# chkconfig: 2345 94 05
# Description: Starts the Teamspeak 3 server
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

# Settings
SERVICENAME='Teamspeak 3 Servers'
SPATH='/home/ts3user/teamspeak3-server/'
SERVICE='/home/ts3user/teamspeak3-server/ts3server_startscript.sh'
OPTIONS='inifile=ts3server.ini'
USERNAME='ts3user'

ME=`whoami`
as_user() {
if [ $ME == $USERNAME ] ; then
bash -c "$1"
else
su - $USERNAME -c "$1"
fi
}

mc_start() {
echo "Starting $SERVICENAME..."
cd $SPATH
as_user "cd $SPATH && $SERVICE start ${OPTIONS}"
}

mc_stop() {
echo "Stopping $SERVICENAME"
as_user "$SERVICE stop"
}

mc_status(){
    # run checks to determine if the service is running or use generic status
    status -p /home/ts3user/teamspeak3-server/ts3server.pid $SERVICENAME
}
mc_status_q(){
    rh_status >/dev/null 2>&1
}

# Start and stop the service here
case "$1" in
start)
mc_start
;;
stop)
mc_stop
;;
restart)
mc_stop
mc_start
;;
status)
mc_status
;;
*)
echo "Usage: /etc/init.d/teamspeak {start|stop|restart|status}"
exit 1
;;
esac

exit 0

Now we will login with our new ts3user created at the beginning of this tutorial, download Teamspeak Server 3 64-bit for Linux and extract in your home directory, get the latest version here: http://www.teamspeak.com/?page=downloads
As TS3User:

cd /home/ts3user/
wget http://dl.4players.de/ts/releases/3.0.11.1/teamspeak3-server_linux-amd64-3.0.11.1.tar.gz
tar -xvf teamspeak3-server_linux-amd64-3.0.11.1.tar.gz
mv teamspeak3-server_linux-amd64 teamspeak3-server
cd teamspeak3-server

As Root:

cp redist/libmariadb.so.2 /lib64/libmariadb.so.2
ldd libts3db_mariadb.so

As Ts3user:
ts3server.ini stores the configuration for the teamspeak server, we need to edit this to work with MySQL instead of SQLite: vi ts3server.ini

machine_id=1
default_voice_port=9987
voice_ip=0.0.0.0
licensepath=
filetransfer_port=30033
filetransfer_ip=0.0.0.0
query_port=10011
query_ip=0.0.0.0
dbplugin=ts3db_mariadb
dbpluginparameter=ts3db_mariadb.ini
dbsqlpath=sql/
dbsqlcreatepath=create_mariadb/
logpath=logs
logquerycommands=0
dbclientkeepdays=30
logappend=0
query_skipbruteforcecheck=0

We must now create a file called ts3db_mariadb.ini, this will hold your database login details:

[config]
host=127.0.0.1
port=3306
username=ts3user
password=ts3password
database=ts3db
socket=

Start Teamspeak:

./ts3server_startscript.sh start

You should now see that teamspeak 3 is installed and you will see a message on screen with a privilege token and your server query admin account details, it is important to copy these as you will need them to administer your server.

Stop the server:

./ts3server_startscript.sh stop

Check the logs in the log directory. if everything is OK, log back in as root, enable the service and start it:

chmod =x /etc/init.d/teamspeak
chkconfig --add teamspeak
chkconfig teamspeak on
service teamspeak start

 

 

 

 

 

Published inCentOSTeamSpeak 3

9 Comments

  1. idx idx

    Hey again 🙂
    Tutorial looks great!
    However, while executing this command” cp redist/libmariadb.so.2 /lib64/libmariadb.so.2″ i got a permission denied
    “cp: cannot create regular file `/lib64/libmariadb.so.2′: Permission denied”
    i tried to load it anyways and it came back with this:
    linux-vdso.so.1 => (0x00007fffd7cae000)
    libmariadb.so.2 => not found
    libm.so.6 => /lib64/libm.so.6 (0x00007f100f557000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f100f1c3000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f100fadd000)

    • Hi, sorry that’s my fault I should have put you need to be logged on with root to perform this command. Also make sure the owner of all the teamspeak3-server files is ts3user:ts3user this must be correct or you will have issues later on.

  2. idx idx

    -On the start line
    do i use the command “./ts3server_startscript.sh start inifile=ts3server.ini”
    in old tutorial u said it tells where the configuration file is….
    or i just do it using “./ts3server_startscript.sh start” ?

    • You don’t need to any more it should pickup the config file as long as it is named ts3server.ini

  3. Mike Mike

    Hey buddy..
    Thx for the tutorial it works great but i have some issues
    1- when i reboot my vps ts wont start cuz access is denied to db with user ts3user
    ” mysql_real_connect() failed with error: Access denied for user ‘ts3user’@’localhost’ (using password: YES) ” (error message from ts3 log )
    also when trying to use this command ” service teamspeak start ” it gives back this error message
    ” CRITICAL|ServerLibPriv | | Server() unable to initialize database ”
    2- i cant upload icons to teamspeak ( cant use file transfer apparently ) error message ” could not open file transfer connection ”
    it might be port problem correct me if im worng
    Thx!

    • Hi Mike,
      1. Please try the following command when logged into MySQL I have found some situations dont like the use of “localhost”
      grant all on ts3db.* to 'ts3user'@'127.0.0.1' identified by 'ts3password';
      flush privileges;

      2. This is due to ports, please make sure you open 30033 that should resolve your issue.

      Steve

  4. Mike Mike

    Hi Steve,
    Replacing ” 127.0.0.1 ” with ” localhost ” fixed the problem somehow..tho i think it created a new db because when TS started it asked me for privilege key..
    and as for the port problem..file transfer port is 30033, i changed that to something else in ” ts3server.ini ” and it works fine now (30033 might be blocked by my VPS host for some reasons )
    Thanks for help.

  5. Traace Traace

    Line 32: Error “su” not found. It happens always. Any script. Whats wrong with them

    • Hi, Im sorry I don’t understand when you are having this issue? If you could let me know I may be able to assist, however SU is part of CentOS operating system by default.

Leave a Reply

Your email address will not be published. Required fields are marked *