MySQL Installation and Configuration

Installing MySQL Server

The TeamDrive Web Portal requires a MySQL database to store its information. This document assumes that the MySQL instance runs on the same host as the Web Portal itself, connecting to it via the local socket file.

Alternatively, it’s possible to use an external MySQL Server. In this case, you need to make sure that this external MySQL instance is reachable via TCP from the Web Portal (usually via TCP port 3306) and that the teamdrive MySQL user account is defined correctly (e.g. the MySQL username in the remote database would become teamdrive@webportal.yourdomain.com instead of teamdrive@localhost).

Most MySQL installations usually do not allow the root user to log in from a remote host. In this case the installation script is unable to create the dedicated teamdrive user automatically and you need to perform this step manually before performing the installation of the TeamDrive Web Portal databases.

Especially the correct definition of the host part is critical, as MySQL considers username@webportal and username@webportal.yourdomain.com as two different user accounts.

Install the MySQL Client and Server packages from the default repository:

dnf install mysql mysql-server

For reliability and performance reasons, we recommend placing the MySQL data directory /var/lib/mysql on a dedicated file system or storage volume.

MySQL 8 requires a charset configuration to work with the Web Portal components. These changes will be done by the mysql_install.sh script later on. The script will update the following config files:

/etc/my.cnf.d/client.cnf
/etc/my.cnf.d/mysql-server.cnf
/etc/my.cnf

Please start the MySQL server now and tell systemd to start the service automatically at boot:

[root@regserver ~ ]# systemctl start mysqld.service
[root@regserver ~ ]# systemctl enable mysqld.service

Run the secure installation script and follow the recommendations:

[root@regserver ~ ]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

The existing password for the user account root has expired. Please set
a new password.

...

Answer the questions with:

  • VALIDATE PASSWORD COMPONENT? N
  • Remove anonymous users? Y
  • Disallow root login remotely? Y
  • Remove test database and access to it? Y
  • Reload privilege tables now? Y

MySQL is now up and running. It will be populated with the required databases and tables during the Registration Server installation process.

Creating TeamDrive MySQL User and Databases

The TeamDrive Web Portal requires the MySQL databases webportal, which will be accessed using a dedicated teamdrive MySQL user.

The Web Portal installation package ships with a mysql_install.sh script that performs these required configuration steps:

  • Modify the local configuration file /etc/my.cnf, start and enable MySQL Server at system bootup (only when using a local MySQL Server)
  • Create the MySQL user account teamdrive, assign the provided password and assign the necessary database privileges (requires access to the MySQL root account)
  • Create the required Web Portal MySQL database
  • Modify the local Web Portal configuration file /etc/td-webportal.my.cnf

The following example demonstrates how to configure the MySQL database using the mysql_install.sh script, it assumes that the MySQL database is located on the same system where the TeamDrive Web Portal instance is installed.

You need to have the following information available:

  • The password of the MySQL root user account you defined while running mysql_secure_installation
  • The password that you want to assign to the teamdrive user

The script is part of the td-webportal package and is installed in /opt/teamdrive/webportal/mysql/mysql_install.sh. Call it as the root user and follow the instructions:

[root@webportal ~]# /opt/teamdrive/webportal/mysql/mysql_install.sh

TeamDrive Web Portal MySQL Database Install Script
--------------------------------------------------

Configuring MySQL database for TeamDrive Web Portal
version |release|

This script will perform the following steps:

 - Modify the local configuration file /etc/my.cnf,
   start and enable MySQL Server
   (only when MySQL Server runs locally)
 - Create the required MySQL user "teamdrive",
   assign the provided password and the required
   database privileges
   (requires access to the MySQL root account)
 - Create and populate the required Web Portal
   MySQL database
 - Modify the local Web Portal configuration file
   /etc/td-webportal.my.cnf

Enter MySQL hostname: localhost
Enter MySQL root password for localhost: <mysql_root_pw>
Enter MySQL password to be set for user teamdrive: <td_pw>

mysqld (pid  7490) is running...
Stopping mysqld:                                           [  OK  ]
Changing local MySQL Server configuration...
Backing up existing configuration file /etc/my.cnf...
`/etc/my.cnf' -> `/etc/my.cnf-2015-05-19-17:19.bak'
Starting and enabling MySQL Server...
Starting mysqld:                                           [  OK  ]
Trying to connect to the MySQL server as root...
+---------------+
| MySQL Version |
+---------------+
| 8.0.21        |
+---------------+
Creating teamdrive MySQL user on localhost
Trying to connect to the MySQL server as the teamdrive user...
Creating Web Portal databases...
Updating /etc/td-webportal.my.cnf...
Backing up existing configuration file ...
`/etc/td-webportal.my.cnf' -> `/etc/td-webportal.my.cnf-2021-03-26-12:44.bak'

Finished!
The MySQL configuration for TeamDrive Web Portal
version |release| is now complete.

The MySQL database is now properly configured and populated. As a final test, try logging into the MySQL database from the Web Portal system, using the teamdrive user account and the password you defined — you should be able to see and access the TeamDrive Web Portal databases:

[root@webportal ~]# mysql -u teamdrive -p<password>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 8.0.21 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| webportal          |
+--------------------+
2 rows in set (0.00 sec)

mysql> QUIT
Bye

CentOS Hardening

We recommend to harden the CentOS system as described in TeamDrive Server Hardening.

The script can be retrieved from TeamDrive Systems.