Mysql: Difference between revisions

From NixOS Wiki
imported>Onny
Initial page
 
imported>Onny
No edit summary
Line 6: Line 6:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
services.mysql.enable = true;
services.mysql = {
  enable = true;
  package = pkgs.mariadb;
};
</syntaxhighlight>
</syntaxhighlight>



Revision as of 16:42, 19 December 2023

MySQL is a widely used open source relational database management system (RDBMS) that offers various features, tools, and services for data warehousing, analytics, machine learning, and more. MariaDB is a popular and stable fork of MySQL that is compatible with MySQL and has additional enhancements and features.

Setup

Setup and enable Mysql (MariaDB) database daemon

services.mysql = {
  enable = true;
  package = pkgs.mariadb;
};

Maintenance

Upgrade

NixOS will not run mysql_upgrade automatically for you after upgrading to a new major version, because it is a "dangerous" operation (can lead to data corruption) and users are strongly advised (by MariaDB upstream) to backup their database before running mysql_upgrade.

mysqldump -u root -p --all-databases > alldb.sql

After backup is completed, you can proceed with the upgrade process

mysql_upgrade