Skip to content

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

NOTE: As of Version 3.0.11.1 this tutorial is no longer applicable. I will soon re-write this to accommodate the latest version.

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!
VIDEO AVAILABLE HERE 
First we need to have mysql installed:

install  mysql-server mysql-common

To use a MySQL database, you need to install additional libraries not available from the default repositories. Download MySQL-shared-compat-6.0.11-0.rhel5.x86_64.rpm (This is 64 bit version. If you are on a 32 bit system, you’ll need to find it somewhere) and install

yum localinstall MySQL-shared-compat-6.0.11-0.rhel5.x86_64.rpm

Now we need to create a new user on our server, this 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 -uroot -p

UPDATE mysql.user SET Password = PASSWORD('password') WHERE User = 'root';
create database ts3db;
grant all on ts3db.* to 'ts3user'@'localhost' identified by 'ts3password';
flush privileges;

Once the MySQL Database is setup 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

wget http://dl.4players.de/ts/releases/3.0.10.3/teamspeak3-server_linux-amd64-3.0.10.3.tar.gz
tar -xf teamspeak3-server_linux-amd64-3.0.10.3.tar.gz
mv teamspeak3-server_linux-amd64-3.0.10.3 teamspeak3-server
cd teamspeak3-server
ldd libts3db_mysql.so

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=
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
query_ip_whitelist=query_ip_whitelist.txt
query_ip_blacklist=query_ip_blacklist.txt
dbplugin=ts3db_mysql
dbpluginparameter=ts3db_mysql.ini
dbsqlpath=sql/
dbsqlcreatepath=create_mysql/
dbconnections=10
logpath=logs
logquerycommands=0
dbclientkeepdays=30
logappend=0

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

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

Start Teamspeak with a few additional paramaters, one tells it where the configuration file is and the other tells it to change the serveradmin password:

./ts3server_startscript.sh start inifile=ts3server.ini serveradmin_password=passwordhere

You should now see that teamspeak 3 is installed and you will see a message on screen with a privelage 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

14 Comments

  1. Thanks for the nice TS3 guide, helped a linux noob like me to get an TS3 server working 🙂

  2. idx idx

    I Followed steps exactly like in your video, till i got to where i should load libraries using this command ” ldd libts3db_mysql.so ”
    When i execute this command i get this msg ” ldd: ./libts3db_mysql.so: No such file or directory ”
    i double check all steps, and im pretty sure i’ve done everything correct..
    so why am i getting this message ?

    • Hi IDX,

      Please make sure the file libmysqlclient.so is here /usr/lib/

      I should have included this in my article. If you don’t have the file download the correct one here and unzip to the /usr/lib/ directory:

      Any issues let me know

  3. idx idx

    Hi Steve, Thanks for you fast reply,
    i couldnt find libmysqlclient.so in /usr/lib/, However i did find it (along with other files with same name, different versions) on here/usr/lib64/ – check this img “http://imgur.com/Z1Ub730”
    i think im not missing that file since i run a CentOS 6 -x64 on my VPS
    i also downloaded the file u mentioned and put it in /usr/lib/….Sadly still having the same error.
    P.S: im pretty much a beginner with Linux and TS
    and btw im the one commented on ur video on YT so u might wana ignore that.

    • I have looked at the logs, could you do an ls -la within the teamspeak3-server directory I just want to check permissions and files are all correct. also ls -la /usr/lib/

      From the logs it looks correct what you have done, Once you have sent me the above would it be possible to get SSH SUDO access to the server? If so I will email directly to get the details, this will allow me to find the issue quicker for you.

    • Ok i have found the issue, Since this article was released teamspeak have changed the way it works with MySQL. I will need to re-write this article to accommodate this.

  4. idx idx

    Oh Great, then…I’ll just have to wait till you write the new one…Hope u do soon
    Thanks very much for your Help.

    • I am currently working on the upgraded version. Essentially you change the ldd libts3db_mysql.so to ldd libys3db_mariadb.so

      Also change the .ini files so that wherever it says MySQL it now says mariadb however I will hopefully be testing this tomorrow so can confirm then.

  5. idx idx

    I think i should wait till you are done with you’re done testing..My Linux Knowledge is still basic.

Leave a Reply

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