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:
$: pkg install mysql80-server mysql80-client
We will now activate the MySQL server and start it for the first time:
$: service mysql-server enable
$: service mysql-server start
By default, no root password is set.
$: mysql -u root
mysql$: alter user 'root'@'localhost' identified by 'your password'; flush privileges; exit;
As a final test, we will log into the newly installed MySQL server with the following statement:
$: 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:
$: pkg install phpMyAdmin-php80
The following hostname is entered /etc/hosts:
127.0.0.1 phpmyadmin.domain
We will use NGINX 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;
}
}