Installation de mariadb sur Alpine Linux
Installation de Mariadb
Installation
# apk add mariadb mysql-client
(1/14) Installing mariadb-common (10.5.9-r0)
(2/14) Installing ca-certificates (20191127-r5)
(3/14) Installing brotli-libs (1.0.9-r3)
(4/14) Installing nghttp2-libs (1.42.0-r1)
(5/14) Installing libcurl (7.76.1-r0)
(6/14) Installing libgcc (10.2.1_pre1-r3)
(7/14) Installing linux-pam (1.5.1-r0)
(8/14) Installing pcre2 (10.36-r0)
(9/14) Installing libstdc++ (10.2.1_pre1-r3)
(10/14) Installing libxml2 (2.9.10-r6)
(11/14) Installing mariadb (10.5.9-r0)
Executing mariadb-10.5.9-r0.pre-install
(12/14) Installing mariadb-openrc (10.5.9-r0)
(13/14) Installing mariadb-client (10.5.9-r0)
(14/14) Installing mysql-client (10.5.9-r0)
Executing busybox-1.32.1-r6.trigger
Executing ca-certificates-20191127-r5.trigger
OK: 283 MiB in 78 packages
Démarrage du service
Si nous essayons de démarrer mariadb de suite, nous obtenons une erreur, et une invitation à lancer le script “/etc/init.d/mariadb setup”.
# rc-service mariadb start
* Caching service dependencies ... [ ok ]
* Datadir '/var/lib/mysql' is empty or invalid.
* Run '/etc/init.d/mariadb setup' to create new database.
* ERROR: mariadb failed to start
Nous exécutons donc le script demandé.
# /etc/init.d/mariadb setup
* Creating a new MySQL database ...
Installing MariaDB/MySQL system tables in '/var/lib/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 mysql@localhost, it has no password either, but
you need to be the system 'mysql' 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 https://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
Nous pouvons alors démarrer le service
# rc-service mariadb start
* Starting mariadb ...
210430 12:36:03 mysqld_safe Logging to syslog.
210430 12:36:03 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql
Nous lançons l’utilitaire de sécurisation de mysql.
# 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]
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]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
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]
... 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]
... 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]
- 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]
... 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!
Enfin, nous nous assurons de démarrer le service Mariadb à chaque redémarrage du serveur.
# rc-update add mariadb default
* service mariadb added to runlevel default