Mysql: Difference between revisions
Appearance
m →Tips: i included a link for the mycli github page |
Yoshino-nya (talk | contribs) m mysql and mariadb_110 were removed from pkgs, use mysql84 and mariadb instead |
||
| Line 6: | Line 6: | ||
= Setup MySQL = | = Setup MySQL = | ||
Setup and enable Mysql database daemon (in this example: | Setup and enable Mysql database daemon (in this example: version 8.4) | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.mysql = { | services.mysql = { | ||
enable = true; | enable = true; | ||
package = pkgs. | package = pkgs.mysql84; | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Setup MariaDB = | = Setup MariaDB = | ||
Setup and enable MariaDB database daemon (in this example: version | Setup and enable MariaDB database daemon (in this example: latest stable version in nixpkgs) | ||
<syntaxhighlight lang="nix">services.mysql = { | <syntaxhighlight lang="nix">services.mysql = { | ||
enable = true; | enable = true; | ||
package = pkgs. | package = pkgs.mariadb; | ||
};</syntaxhighlight> | };</syntaxhighlight> | ||
= Tips = | = Tips = | ||
Latest revision as of 12:30, 11 September 2026
MySQL and MariaDB are installed via the same services.mysql configuration.
- 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 MySQL
Setup and enable Mysql database daemon (in this example: version 8.4)
services.mysql = {
enable = true;
package = pkgs.mysql84;
};
Setup MariaDB
Setup and enable MariaDB database daemon (in this example: latest stable version in nixpkgs)
services.mysql = {
enable = true;
package = pkgs.mariadb;
};
Tips
install mycli to get autocompletion when working with mysql/mariadb
environment.systemPackages = [ pkgs.mycli ];
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