https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Andaris&feedformat=atomAlpine Linux - User contributions [en]2024-03-28T14:41:49ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=MariaDB&diff=15961MariaDB2019-05-23T07:53:36Z<p>Andaris: Remove setup SQL file (with credentials) after applying it</p>
<hr />
<div>[https://mariadb.org/ 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.<br />
<br />
= Setup =<br />
MariaDB packages can be installed by running<br />
{{cmd|apk add mariadb mariadb-client}}<br />
<br />
Defining variables that will be used for setup and configuration<br />
{{cmd|<nowiki>DB_DATA_PATH="/var/lib/mysql"<br />
DB_ROOT_PASS="mariadb_root_password"<br />
DB_USER="mariadb_user"<br />
DB_PASS="mariadb_user_password"<br />
MAX_ALLOWED_PACKET="200M"</nowiki>}}<br />
<br />
Installing mysql database<br />
{{cmd|<nowiki>mysql_install_db --user=mysql --datadir=${DB_DATA_PATH}</nowiki>}}<br />
<br />
Starting service<br />
{{cmd|rc-service mariadb start}}<br />
<br />
You should get something like<br />
<pre><br />
* Caching service dependencies ... [ ok ]<br />
* Starting mariadb ...<br />
161122 09:23:06 mysqld_safe Logging to syslog. [ ok ]<br />
</pre><br />
<br />
Setting root password<br />
{{cmd|<nowiki>mysqladmin -u root password "${DB_ROOT_PASS}"</nowiki>}}<br />
<br />
Creating new user, removing security sensitive data<br />
{{cmd|<nowiki>echo "GRANT ALL ON *.* TO ${DB_USER}@'127.0.0.1' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" > /tmp/sql<br />
echo "GRANT ALL ON *.* TO ${DB_USER}@'localhost' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" >> /tmp/sql<br />
echo "GRANT ALL ON *.* TO ${DB_USER}@'::1' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" >> /tmp/sql<br />
echo "DELETE FROM mysql.user WHERE User='';" >> /tmp/sql<br />
echo "DROP DATABASE test;" >> /tmp/sql<br />
echo "FLUSH PRIVILEGES;" >> /tmp/sql<br />
cat /tmp/sql | mysql -u root --password="${DB_ROOT_PASS}"<br />
rm /tmp/sql</nowiki>}}<br />
<br />
Modifying configuration file /etc/mysql/my.cnf<br />
{{cmd|<nowiki>sed -i "s|max_allowed_packet\s*=\s*1M|max_allowed_packet = ${MAX_ALLOWED_PACKET}|g" /etc/mysql/my.cnf<br />
sed -i "s|max_allowed_packet\s*=\s*16M|max_allowed_packet = ${MAX_ALLOWED_PACKET}|g" /etc/mysql/my.cnf</nowiki>}}<br />
<br />
Normally you want to start the MariaDB server when the system is launching. This is done by adding MariaDB to the needed runlevel.<br />
{{cmd|rc-update add mariadb default}}<br />
<br />
Now MariaDB server should start automatically when you launch your system next time. To test that run:<br />
{{cmd|reboot}}<br />
<br />
To make sure that mysql started run:<br />
{{cmd|<nowiki>ps aux | grep mysql</nowiki>}}<br />
<br />
You should get something like this:<br />
<pre><br />
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<br />
383 root 0:00 logger -t mysqld -p daemon.error<br />
</pre><br />
<br />
[[Category:SQL]]<br />
[[Category:Server]]</div>Andarishttps://wiki.alpinelinux.org/w/index.php?title=MariaDB&diff=15960MariaDB2019-05-23T07:51:05Z<p>Andaris: Fix typo</p>
<hr />
<div>[https://mariadb.org/ 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.<br />
<br />
= Setup =<br />
MariaDB packages can be installed by running<br />
{{cmd|apk add mariadb mariadb-client}}<br />
<br />
Defining variables that will be used for setup and configuration<br />
{{cmd|<nowiki>DB_DATA_PATH="/var/lib/mysql"<br />
DB_ROOT_PASS="mariadb_root_password"<br />
DB_USER="mariadb_user"<br />
DB_PASS="mariadb_user_password"<br />
MAX_ALLOWED_PACKET="200M"</nowiki>}}<br />
<br />
Installing mysql database<br />
{{cmd|<nowiki>mysql_install_db --user=mysql --datadir=${DB_DATA_PATH}</nowiki>}}<br />
<br />
Starting service<br />
{{cmd|rc-service mariadb start}}<br />
<br />
You should get something like<br />
<pre><br />
* Caching service dependencies ... [ ok ]<br />
* Starting mariadb ...<br />
161122 09:23:06 mysqld_safe Logging to syslog. [ ok ]<br />
</pre><br />
<br />
Setting root password<br />
{{cmd|<nowiki>mysqladmin -u root password "${DB_ROOT_PASS}"</nowiki>}}<br />
<br />
Creating new user, removing security sensitive data<br />
{{cmd|<nowiki>echo "GRANT ALL ON *.* TO ${DB_USER}@'127.0.0.1' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" > /tmp/sql<br />
echo "GRANT ALL ON *.* TO ${DB_USER}@'localhost' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" >> /tmp/sql<br />
echo "GRANT ALL ON *.* TO ${DB_USER}@'::1' IDENTIFIED BY '${DB_PASS}' WITH GRANT OPTION;" >> /tmp/sql<br />
echo "DELETE FROM mysql.user WHERE User='';" >> /tmp/sql<br />
echo "DROP DATABASE test;" >> /tmp/sql<br />
echo "FLUSH PRIVILEGES;" >> /tmp/sql<br />
cat /tmp/sql | mysql -u root --password="${DB_ROOT_PASS}"</nowiki>}}<br />
<br />
Modifying configuration file /etc/mysql/my.cnf<br />
{{cmd|<nowiki>sed -i "s|max_allowed_packet\s*=\s*1M|max_allowed_packet = ${MAX_ALLOWED_PACKET}|g" /etc/mysql/my.cnf<br />
sed -i "s|max_allowed_packet\s*=\s*16M|max_allowed_packet = ${MAX_ALLOWED_PACKET}|g" /etc/mysql/my.cnf</nowiki>}}<br />
<br />
Normally you want to start the MariaDB server when the system is launching. This is done by adding MariaDB to the needed runlevel.<br />
{{cmd|rc-update add mariadb default}}<br />
<br />
Now MariaDB server should start automatically when you launch your system next time. To test that run:<br />
{{cmd|reboot}}<br />
<br />
To make sure that mysql started run:<br />
{{cmd|<nowiki>ps aux | grep mysql</nowiki>}}<br />
<br />
You should get something like this:<br />
<pre><br />
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<br />
383 root 0:00 logger -t mysqld -p daemon.error<br />
</pre><br />
<br />
[[Category:SQL]]<br />
[[Category:Server]]</div>Andaris