Install and Configure FreeRADIUS with MySQL on Ubuntu is an effective solution to create a scalable authentication infrastructure for networks of all sizes. Combining one of the most popular open source-based Radius servers with a MySQL database provides efficient management of user information, monitoring, and keeping records in a reliable structure. Such solution is beneficial for Internet Service Providers, large corporations, hotspots, or any organization where centralized user authentication and logs are required. This article will describe step-by-step installation and configuration process of such a stack in Ubuntu distribution.
Update the Server Packages
To begin the process of Install and Configure FreeRADIUS with MySQL on Ubuntu, it’s important to make sure your system is fully up to date. Refresh the package lists and upgrade existing software to avoid compatibility issues during installation.
sudo apt update
sudo apt upgrade
Install Apache2 Web Server
As part of the workflow to Install and Configure FreeRADIUS with MySQL on Ubuntu, you’ll need a reliable web server. Apache2 is a popular choice thanks to its stability and wide support, so we install it next.
sudo apt -y install apache2

WordPress Web Hosting
Starting From $3.99/Monthly
Install PHP and Required Extensions
For proper functionality, especially if you plan to use web-based management tools, PHP and its necessary modules must be installed. This step ensures your environment is ready for database interaction and web integration while you Install and Configure FreeRADIUS with MySQL on Ubuntu.
sudo apt -y install php libapache2-mod-php php-{gd,common,mail,mail-mime,mysql,pear,db,mbstring,xml,curl}
Install MySQL Database Server
A database is essential for storing user credentials and accounting data. While MySQL is used in this guide, MariaDB can also be an alternative. Installing the database server is a key step in Install and Configure FreeRADIUS with MySQL on Ubuntu.
sudo apt -y install mysql-server
Secure and Configure MySQL
After installation, it’s necessary to secure the database server. Run the built-in security script to configure important settings and remove default vulnerabilities.
sudo mysql_secure_installation
Cheap VPS Server
Starting From $2.99/Monthly
During this setup, you’ll be prompted to choose password validation settings. In this case, selecting “No” keeps things simple for initial setup, meaning no root password is enforced by default (you can configure it later). The script will then guide you through several security options.
Password Validation and Initial Security Prompts
The following section explains password policy settings and general database security recommendations. For simplicity, skip the validation component:
Press y|Y for Yes, any other key for No: n
Remove Anonymous Users
By default, MySQL includes anonymous users for testing purposes. These should be removed to improve security in production environments.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Restrict Root Login Access
To enhance security further, it’s recommended to prevent remote root logins. This ensures only local access is allowed for administrative tasks.
Windows VPS Hosting
Remote Access & Full Admin
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove the Default Test Database
As you continue the process of Install and Configure FreeRADIUS with MySQL on Ubuntu, it’s important to eliminate unnecessary components. MySQL includes a default database called test that is accessible to all users and meant just for test. Keeping it in a production environment is a security risk, so it should be removed.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Apply Changes by Reloading Privileges
After making structural changes to MySQL, you need to reload the privilege tables so the updates take effect immediately. This is a critical step when you Install and Configure FreeRADIUS with MySQL on Ubuntu because permissions must be accurate from the start.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
At this point, the MySQL setup is complete and ready for integration.
Install FreeRADIUS Packages
Now we move forward with installing FreeRADIUS along with its MySQL module and utility tools. This step is the core of the Install and Configure FreeRADIUS with MySQL on Ubuntu workflow.
sudo apt -y install freeradius freeradius-mysql freeradius-utils -y
Test FreeRADIUS Installation
Before making any configurations, it’s smart to verify that FreeRADIUS is working correctly. First, stop the service:
sudo systemctl stop freeradius
Then start it in debug mode. This allows you to see real-time logs, which are extremely useful for troubleshooting during the Install and Configure FreeRADIUS with MySQL on Ubuntu process.
sudo freeradius -X
If everything is working properly, you’ll see output similar to this:
Listening on auth address * port 1812 bound to server default
Listening on acct address * port 1813 bound to server default
Listening on auth address :: port 1812 bound to server default
Listening on acct address :: port 1813 bound to server default
Listening on auth address 127.0.0.1 port 18120 bound to server inner-tunnel
Listening on proxy address * port 33201
Listening on proxy address :: port 59970
Ready to process requests

Configure MySQL for FreeRADIUS
Next, we prepare the database specifically for FreeRADIUS. Since no root password was set earlier, simply press Enter when prompted.
sudo mysql -u root -p
Inside MySQL, create the database and user. These credentials will later be used by FreeRADIUS. This step is a key part of successfully completing Install and Configure FreeRADIUS with MySQL on Ubuntu.
CREATE DATABASE radius;
CREATE USER 'radius'@'localhost' IDENTIFIED by 'helloworld123';
GRANT ALL PRIVILEGES ON radius.* TO 'radius'@'localhost';
FLUSH PRIVILEGES;
quit;
Switch to Root User
For the next configuration steps, you’ll need root-level access. Switch to the root user with the following command:
sudo su -
Install and Configure FreeRADIUS with MySQL on Ubuntu – Import Database Schema
To begin, you need to load the required database structure for FreeRADIUS into the database you created earlier. This ensures all necessary tables are ready for use.
mysql -u root -p radius < /etc/freeradius/3.0/mods-config/sql/main/mysql/schema.sql
Install and Configure FreeRADIUS with MySQL on Ubuntu – Enable SQL Module
Next, create a symbolic link to activate the SQL module by linking the available configuration to the enabled directory:
sudo ln -s /etc/freeradius/3.0/mods-available/sql /etc/freeradius/3.0/mods-enabled/
Install and Configure FreeRADIUS with MySQL on Ubuntu – Edit SQL Configuration
Now it’s time to modify the SQL configuration file. Open it using the nano editor. You can search inside the file using Ctrl + W or navigate using arrow keys:
sudo nano /etc/freeradius/3.0/mods-enabled/sql
Locate the driver setting and switch it from the default null driver to the SQL dialect driver. Comment out the first line and activate the second:
driver = "rlm_sql_null"# driver = "rlm_sql_${dialect}"
After editing, it should appear like this:
# driver = "rlm_sql_null" driver = "rlm_sql_${dialect}"
Install and Configure FreeRADIUS with MySQL on Ubuntu – Set MySQL as Dialect
Find the dialect option and change it from SQLite to MySQL:
dialect = "sqlite" dialect = "mysql"
Configure TLS Section for MySQL Connection
Search for the mysql { block and then the tls { subsection. Disable all TLS-related lines by commenting them out, except for the warnings = auto line which should remain active:
mysql {
# If any of the files below are set, TLS encryption is enabled
tls {
ca_file = "/etc/ssl/certs/my_ca.crt"
ca_path = "/etc/ssl/certs/"
certificate_file = "/etc/ssl/certs/private/client.crt"
private_key_file = "/etc/ssl/certs/private/client.key"
cipher = "DHE-RSA-AES256-SHA:AES128-SHA"
tls_required = yes
tls_check_cert = no
tls_check_cert_cn = no
}
# If yes, (or auto and libmysqlclient reports warnings are
# available), will retrieve and log additional warnings from
# the server if an error has occured. Defaults to 'auto'
warnings = auto
}
After making changes, it should look like this:
mysql {
# If any of the files below are set, TLS encryption is enabled
#tls {
# ca_file = "/etc/ssl/certs/my_ca.crt"
# ca_path = "/etc/ssl/certs/"
# certificate_file = "/etc/ssl/certs/private/client.crt"
# private_key_file = "/etc/ssl/certs/private/client.key"
# cipher = "DHE-RSA-AES256-SHA:AES128-SHA"
# tls_required = yes
# tls_check_cert = no
# tls_check_cert_cn = no
#}
# If yes, (or auto and libmysqlclient reports warnings are
# available), will retrieve and log additional warnings from
# the server if an error has occured. Defaults to 'auto'
warnings = auto
}
Configure Database Connection Details
Finally, scroll down to the connection settings section. Remove the comment symbols (#) and update the credentials based on what you defined when creating a database:
# Connection info:
#
# server = "localhost"
# port = 3306
# login = "radius"
# password = "radpass"
Modify it like this (replace the password with your actual one):
# Connection info:
#
server = "localhost"
port = 3306
login = "radius"
password = "helloworld123"
Install and Configure FreeRADIUS with MySQL on Ubuntu – Database Name Configuration
At this stage, you need to verify the database name used by FreeRADIUS. Since the default database name was used during setup, there is no need to modify it here.
radius_db = "radius"
Enable Client Reading
Next, locate the read_clients option in the configuration file. This setting allows FreeRADIUS to load client devices directly from the database. Simply remove the comment symbol (#) to activate it.
# read_clients = yes
read_clients = yes
Client Table Configuration
By default, FreeRADIUS uses the nas table to store client device information (such as routers or access points like MikroTik). If you plan to use a different table name, you can adjust it here.
client_table = "nas"
Install and Configure FreeRADIUS with MySQL on Ubuntu – Set Permissions and Restart Service
Before finishing, make sure the correct permissions are applied to the SQL configuration files. This ensures FreeRADIUS can properly access and use them.
sudo chgrp -h freerad /etc/freeradius/3.0/mods-available/sql
sudo chown -R freerad:freerad /etc/freeradius/3.0/mods-enabled/sql
Finally, restart the FreeRADIUS service to apply all the changes you’ve made:
sudo systemctl restart freeradius.service
installing and configuring FreeRADIUS with MySQL on Ubuntu
In this guide, we walked through installing and configuring FreeRADIUS with MySQL on Ubuntu, creating a powerful and scalable authentication system. By integrating MySQL, you gain better control over user management, accounting, and data storage compared to flat-file configurations. We covered package installation, database setup, schema import, and proper configuration of FreeRADIUS to communicate with MySQL. Testing and troubleshooting steps ensure everything runs smoothly. Overall, this setup is ideal for environments that require centralized authentication, such as ISPs, enterprise networks, or hotspot systems, providing flexibility, reliability, and easier long-term maintenance for growing infrastructures.