Install and configure MySQL Server on FreeBSD

I will show you in this tutorial, how to install and configure MySQL Server on FreeBSD operating system.

MySQL Server installation

To install MySQL Server enter in terminal/ssh this command :

pkg install mysql57-server

root@freebsdsrv:~ # pkg install mysql57-server
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 15 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    ca_root_nss: 3.58
    curl: 7.74.0
    cyrus-sasl: 2.1.27_1
    groff: 1.22.4_3
    libedit: 3.1.20191231,1
    libevent: 2.1.12
    liblz4: 1.9.3,1
    libnghttp2: 1.42.0
    libpaper: 1.1.24.4
    mysql57-client: 5.7.33
    mysql57-server: 5.7.33
    perl5: 5.32.1_1
    protobuf: 3.13.0,1
    psutils: 1.17_5
    uchardet: 0.0.7

Number of packages to be installed: 15

The process will require 308 MiB more space.
39 MiB to be downloaded.

Proceed with this action? [y/N]: 

enter y and hit enter.

MySQL Server configuration

After installation is done, first enable MySQL in /etc/rc.conf with this command :

sysrc mysql_enable=YES

Then start MySQL server with this command :
service mysql-server start

root@freebsdsrv:~ # service mysql-server start
Starting mysql.


To Check status of MySQL server enter :
service mysql-server status

root@freebsdsrv:~ # service mysql-server status
mysql is running as pid 60209.


Now lunch the folowing command to secure your MySQL installation :
mysql_secure_installation

For first question reply with no (strength of password) and to yes to all other questions.

root@freebsdsrv:~ # mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL server using password in '/root/.mysql_secret'

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:

Re-enter new password:
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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

MySQL has a default configuration file located in /usr/local/etc/mysql/my.cnf

Popular posts from this blog

Linux Mint : 26 Reasons Why I Use It And You Should Too

How to create an AppImage to bundle your software

SEO Services Primelis Company: Rank Fast in Google