14 C
Texas
angeloma
Senior Writer and partner

How to install MariaDB on FreeBSD 12?

They say behind a great application is a great database manager. This applies to applications designed to solve a major problem within an organization or management applications. An example of this is WordPress, a powerful CMS that uses MariaDB as a data handler. So today I will show you how to install MariaDB on FreeBSD.

Why the combination of MariaDB and FreeBSD?

FreeBSD is a Unix based system that for many experts is even more secure than Linux. And we already know that Linux is widely used in servers around the world, however, more and more people are using FreeBSD on them.

On the other hand, on many servers, there is an instance of some SQL database manager like MariaDB. Also being this one of the most used database managers in the world along with MySQL and PostgreSQL, it is not surprising that you want to install it on FreeBSD 12.

So the combination between MariaDB and FreeBSD 12 as a database server is a sure success in security.

- Advertisement -

So let’s go for it.

Install MariaDB on FreeBSD 12

For this guide, we will use the sudo command, therefore, it must be enabled. So we recommend you to read:

How to enable sudo on FreeBSD 12?

So, open a terminal session or connect to the computer using SSH.

Then, update the whole system with the following command:

:~$ sudo pkg update

Once all security patches are installed, the system is ready to continue.

The purpose of this guide is to install MariaDB but there are several versions in the official FreeBSD 12 repositories. However, we will install the last one which is 10.4.

To do this, run the following command:

:~$ sudo pkg install mariadb104-server mariadb104-client php74-mysqli
Updating FreeBSD repository catalogue... 
FreeBSD repository is up to date. 
All repositories are up to date. 
The following 9 package(s) will be affected (of 0 checked):

New packages to be INSTALLED: 
mariadb104-server: 10.4.12 
mariadb104-client: 10.4.12 
php74-mysqli: 7.4.2 
libedit: 3.1.20191211,1 
unixODBC: 2.3.7 
galera26: 26.4.2_1 
boost-libs: 1.72.0 
icu: 65.1,1 
libiconv: 1.14_11

Number of packages to be installed: 9

The process will require 472 MiB more space. 
57 MiB to be downloaded.

Proceed with this action? [y/N]:

1.- Install MariaDB on FreeBSD 12
1.- Install MariaDB on FreeBSD 12

Once installed, it is most convenient to enable the service to start with the system. In short, MariaDB will run when the computer starts up.

:~$ sudo sysrc mysql_enable="yes"
mysql_enable: -> yes

And then the service begins.

:~$ sudo service mysql-server start

Installing MariaDB/MySQL system tables in '/var/db/mysql' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is root@localhost, it has no password either, but
you need to be the system 'root' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr/local' ; /usr/local/bin/mysqld_safe --datadir='/var/db/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
Get Involved
Starting mysql.

2.- Working with the MariaDB service
2.- Working with the MariaDB service

Now you have to assign a password to the root user. To do this we’ll use the mysql_secure_installation script. Execute it and assign a password to the root user.

:~$ sudo /usr/local/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, 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 MariaDB 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] y
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] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

Then, answer the configuration questions. In my case, I answered yes to everything.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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] y
... 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] y
... Success!

By default, MariaDB 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] y
- 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] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

3.- Configuring MariaDB on FreeBSD
3.- Configuring MariaDB on FreeBSD

Now MariaDB is ready for you to use it.

:~$ sudo mysql -u root -p

4.- MariaDB is ready for the action
4.- MariaDB is ready for the action

And that is it.

Conclusion

MariaDB is one of the most stable and robust database managers in the world. Installing it on FreeBSD 12 gives us a stable computer to run it on. And today thanks to this post you have learned how to do it.

Please share this post and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article