Install MySQL on FreeBSD

In this post I will tell you how to install MySQL on FreeBSD


MySQL is one of the most popular relational database management systems in the world.

So that we can install the MySQL database under FreeBSD, we need the packages mysql80-server and mysql80-client.

We'll install the whole thing with the following command:

root: pkg install mysql80-server mysql80-client

We will now activate the MySQL server and start it for the first time:

root: service mysql-server enable
root: service mysql-server start

Then we will do the following:

root: /usr/local/bin/mysql_secure_installation

As a final test, we will log into the newly installed MySQL server with the following statement:

root: mysql -u root -p

phpMyAdmin

phpMyAdmin is a free web application for the administration of MySQL databases and their fork, MariaDB. The software is implemented in PHP, hence the name phpMyAdmin.

We will install the phpmyadmin package with the following command:

root: pkg install phpMyAdmin-php74

The following host name is entered /etc/hosts:

127.0.0.1 phpmyadmin.

We will use NGINX s as the web server. So that phpMyAdmin runs under NGINX, the following file is created under /usr/local/etc/nginx/vhosts/ under the name phpmyadmin.conf with this content:

Server {
    listen 80;
    server_name phpmyadmin.<domain>;

    root /usr/local/www/phpMyAdmin/;
    index index.php;

    location ~\.php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
    }
}