MySQL is an open-source relational database management system. Its one of the popular relational management system.
Mysql is commonly installed as part of the popular LAMP or LEMP (Linux, Apache/Nginx, MySQL/MariaDB, PHP/Python/Perl) stack. It implements the relational model and Structured Query Language (SQL) to manage and query data.
In this guide we are going to install mysql 8 on FreeBSD 13.
- How to install Mysql Server 8 on Debian 11
- How to install Mysql Server 8 on OpenSUSE Leap 15.3
- How to install and Configure Mysql Server 8 on Fedora 34/35
- How to install Mysql 8 on Rocky Linux/Centos 8
- How to Install and Set Up mysql 8 on Ubuntu 20.04
- How to run Mysql 8 with Docker and Docker-Compose
- Using Ansible to Install and Initialize Mysql 8 on Centos 8
- Mysql Permissions – Create, Update, Delete Database Users
- Install and Setup Nginx, WordPress and Mysql 8 in Centos 8
- Create an RDS instance in terraform with a Mariadb Example
Table of Content
- Ensuring the server is Up to date
- Set up the repo for mysql 8 installation
- Installing Mysql 8 server
- Starting and enabling mysql service
- Configuring mysql
- Testing mysql installation
1. Ensuring the Server is Up to date
Before proceeding, let us ensure that our debian server is up to date. Use this command to update the server packages:
Next, let us install common packages that we will need in our tutorial
pkg install -y curl vim
2. Installing Mysql 8 server
The Mysql server 8 package is available as
mysql80-server in freebsd. Install it using this command:
pkg install -y mysql80-server
The system will install the MySQL server package, client packages, and database common files.
4. Starting and enabling mysql service
In FreeBSD, Mysql server will be started by default. Enable and start mysql server using these commands. Enable:
# sysrc mysql_enable=yes mysql_enable: -> yes
Then start the service
service mysql-server start
Check the status of the service to confirm that it is actually running:
# service mysql-server status mysql is running as pid 2913.
5. Configuring mysql
For new Mysql installations, the next step is to run the included security script. This script changes some of the less secure default options. We will use it to block remote root logins and to remove unused database users.
Run the security script:
This will take you through a series of prompts where you can make some changes to your Mysql installation’s security options. The first prompt will ask you to enter the current database root password. Since we have not set one up yet, press
ENTER to indicate “none”.
The next prompt asks you whether you’d like to set up a database root password. Type
N and then press
ENTER. The root account for Mysql is tied closely to automated system maintenance, so we should not change the configured authentication methods for that account. Doing so would make it possible for a package update to break the database system by removing access to the administrative account. Later, we will cover how to optionally set up an additional administrative account for password access if socket authentication is not appropriate for your use case.
From there, you can press
Y and then
ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that Mysql immediately respects the changes you have made.
This is my server’s output
# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL Mysql SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into Mysql to secure it, we'll need the current password for the root user. If you've just installed Mysql, and haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the Mysql root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] Enabled successfully! Reloading privilege tables.. ... Success! You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a Mysql installation has an anonymous user, allowing anyone to log into Mysql without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] ... Success! By default, Mysql comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] ... Success! Cleaning up... All done! If you've completed all of the above steps, your Mysql installation should now be secure. Thanks for using Mysql!
6. Testing MySQL Installation
Let us check mysql version with this command:
# mysql -V mysql Ver 8.0.27 for FreeBSD13.0 on amd64 (Source distribution)
Now you can Login as the
root user and the password specified above.
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.27 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 owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. [email protected] [(none)]> select version(); +-----------+ | version() | +-----------+ | 8.0.27 | +-----------+ 1 row in set (0.00 sec) [email protected] [(none)]>
In this article, we managed to install and test Mysql server 8 installation on FreeBSD 13.