Skip to Content

How to Install MySQL Server on FreeBSD

This tutorial shows you how to install MySQL Server on a FreeBSD system.

FreeBSD simplifies software management with its packaging system and ports collection. Packages and ports automate the install, uninstall, and configuration process of thousands of software packages.

Let’s take a look at how to install MySQL on FreeBSD with the package manager.

Install with Package Manager

1. Switch to the root user.

su -

2. Update FreeBSD repository.

pkg update

If it’s your first time running the pkg update command, you might be asked to install the package management tool.

The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: 

Type y and hit ENTER to install the package management tool and update the repositories.

3. Now we can install MySQL with the following command.

pkg install mysql80-server mysql80-client

Note: If you want to install a different version of MySQL you can search for different packages using pkg search mysql.

4. Enable MySQL so that it starts when FreeBSD boots.

service mysql-server enable

5. Start MySQL now.Advertisements

service mysql-server start

Test MySQL

You should now be able to login as the root user with the MySQL client by running the following command.

mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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

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

root@localhost [(none)]>