Difference between revisions of "MariaDB"

From Alpine Linux
Jump to: navigation, search
m (single quotes does not evaluate an variable so password is set to literal ${DB_ROOT_PASS})
Line 47: Line 47:
To make sure that Nginx and PHP are started run:
To make sure that mysql started run:
{{cmd|<nowiki>ps aux | grep mysql</nowiki>}}
{{cmd|<nowiki>ps aux | grep mysql</nowiki>}}

Revision as of 15:28, 14 January 2019

MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. It is notable for being led by the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle.


MariaDB packages can be installed by running

apk add mariadb mariadb-client

Defining variables that will be used for setup and configuration

DB_DATA_PATH="/var/lib/mysql" DB_ROOT_PASS="mariadb_root_password" DB_USER="mariadb_user" DB_PASS="mariadb_user_password" MAX_ALLOWED_PACKET="200M"

Installing mysql database

mysql_install_db --user=mysql --datadir=${DB_DATA_PATH}

Starting service

rc-service mariadb start

You should get something like

 * Caching service dependencies ...                       [ ok ]
 * Starting mariadb ...
161122 09:23:06 mysqld_safe Logging to syslog.            [ ok ]

Setting root password

mysqladmin -u root password "${DB_ROOT_PASS}"

Creating new user, removing sequrity sensitive data

echo "GRANT ALL ON *.* TO ${DB_USER}@'' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" > /tmp/sql echo "GRANT ALL ON *.* TO ${DB_USER}@'localhost' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" >> /tmp/sql echo "GRANT ALL ON *.* TO ${DB_USER}@'::1' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" >> /tmp/sql echo "DELETE FROM mysql.user WHERE User='';" >> /tmp/sql echo "DROP DATABASE test;" >> /tmp/sql echo "FLUSH PRIVILEGES;" >> /tmp/sql cat /tmp/sql | mysql -u root --password="${DB_ROOT_PASS}"

Modifying configuration file /etc/mysql/my.cnf

sed -i "s|max_allowed_packet\s*=\s*1M|max_allowed_packet = ${MAX_ALLOWED_PACKET}|g" /etc/mysql/my.cnf sed -i "s|max_allowed_packet\s*=\s*16M|max_allowed_packet = ${MAX_ALLOWED_PACKET}|g" /etc/mysql/my.cnf

Normally you want to start the MariaDB server when the system is launching. This is done by adding MariaDB to the needed runlevel.

rc-update add mariadb default

Now MariaDB server should start automatically when you launch your system next time. To test that run:


To make sure that mysql started run:

ps aux | grep mysql

You should get something like this:

  382 mysql      0:00 /usr/bin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/run/mysqld/mysqld.pid --socket=/run/mysqld/mysqld.sock --port=3306
  383 root       0:00 logger -t mysqld -p daemon.error