This post shows how to install MariaDB on OpenBSD and set it up.
MariaDB is an open source software providing a great relational database server.
It's famous as a folk of MySQL.
I like the side story about their names.
Michael "Monty" Widenius is one of the founders of MySQL AB, and now CTO of the MariaDB Corporation AB.
MariaDB is named after Maria, his younger daughter as MySQL is named after My, his elder daughter 😄
I have moved from MySQL to MariaDB from the point of view of the security maintenance.
As to PostgreSQL, I like both MariaDB and PostgreSQL.
MariaDB is multi-threaded and so seem lightweight, and PostgreSQL is multi-processed and so seem robust.
I have seemed to use MariaDB more frequently than PostgreSQL recently, but it's not always the case.
Environment
- OS: OpenBSD 6.4 amd64
- DB: MariaDB 10.0
Procedure
* note: In code areas, the leading #
means execution by superuser; It is equal to using doas
command (as root), while the leading $
means by general users.
Install package
# pkg_add mariadb-server
Enable MariaDB daemon which is called as 'mysqld':
# rcctl enable mysqld
# # check it
# cat /etc/rc.conf.local
...
pkg_scripts=mysqld
...
Prepare system
# mysql_install_db
Installing MariaDB/MySQL system tables in '/var/mysql' ...
...
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/local/bin/mysqladmin' -u root password 'new-password'
'/usr/local/bin/mysqladmin' -u root -h [host] password 'new-password'
Alternatively you can run:
'/usr/local/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
/etc/rc.d/mysqld start
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:
https://mariadb.org/get-involved/
Start MariaDB server
# rcctl start mysqld
mysqld(ok)
Initialize database
Run mysql_secure_installation
and then follow several steps answering the questions.
The answers below are my examples.
# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
Question #1 (Just click Enter for the first time):
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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Question #2:
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Question #3:
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!
Question #4:
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!
Question #5:
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!
Question #6:
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!
(Finished!) Now DDL and DML are available
In order to access MariaDB server as client, mysql
command is available as well as MySQL:
$ mysql -u root -p
DDL examples:
CREATE DATABASE %database%;
-- CREATE USER '%user%'@'%host%' IDENTIFIED BY '%password%';
GRANT ALL PRIVILEGES ON %database%.* TO '%user'@'%host%' IDENTIFIED BY '%password%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
DML examples:
> select 'Hello, world.' as greetings;
+---------------+
| greetings |
+---------------+
| Hello, world. |
+---------------+
1 row in set (0.00 sec)
Thank you very much for your reading.
I'm happy if this post helps someone in some way : )
Top comments (0)