[Nix-dev] How to use MySQL
Linus Arver
linusarver at gmail.com
Mon Oct 3 10:21:32 CEST 2016
Hello all,
I want to install and use MySQL on NixOS, but am not sure how to
proceed. I've managed to do
nix-env -iA nixos.mysql55
but trying to get it to run is difficult. Here is what I tried:
[月 03 0:50:47] - l_k0 ~/prog/sqfmm/mysql
> mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
[月 03 0:50:53] 1 - l_k0 ~/prog/sqfmm/mysql
> systemctl start mysqld
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'mysqld.service'.
Multiple identities can be used for authentication:
1. System administrator (root)
2. Linus Arver (l)
Choose identity to authenticate as (1-2): 2
Password:
==== AUTHENTICATION COMPLETE ===
Failed to start mysqld.service: Unit mysqld.service not found.
[月 03 0:52:33] 5 - l_k0 ~/prog/sqfmm/mysql
> systemctl start mysql
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'mysql.service'.
Multiple identities can be used for authentication:
1. System administrator (root)
2. Linus Arver (l)
Choose identity to authenticate as (1-2): 2
Password:
==== AUTHENTICATION COMPLETE ===
Failed to start mysql.service: Unit mysql.service not found.
[月 03 0:52:57] 5 - l_k0 ~/prog/sqfmm/mysql
> mysqld
161003 0:53:16 [Note] mysqld (mysqld 5.5.50) starting as process 12363 ...
161003 0:53:16 [Warning] Can't create test file /var/lib/mysql/k0.lower-test
161003 0:53:16 [Warning] Can't create test file /var/lib/mysql/k0.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2)
161003 0:53:16 [ERROR] Aborting
161003 0:53:16 [Note] mysqld: Shutdown complete
[月 03 0:53:16] 1 - l_k0 ~/prog/sqfmm/mysql
> mysqld_safe
161003 00:54:16 mysqld_safe Logging to '/var/lib/mysql/k0.err'.
touch: cannot touch '/var/lib/mysql/k0.err': No such file or directory
chmod: cannot access '/var/lib/mysql/k0.err': No such file or directory
mkdir: cannot create directory ‘/run/mysqld’: Permission denied
chown: invalid user: ‘mysql’
chmod: cannot access '/run/mysqld': No such file or directory
161003 00:54:16 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/home/l/.nix-profile/bin/mysqld_safe: line 128: /var/lib/mysql/k0.err: No such file or directory
/home/l/.nix-profile/bin/mysqld_safe: line 165: /var/lib/mysql/k0.err: No such file or directory
touch: cannot touch '/var/lib/mysql/k0.err': No such file or directory
chown: invalid user: ‘mysql’
chmod: cannot access '/var/lib/mysql/k0.err': No such file or directory
161003 00:54:16 mysqld_safe mysqld from pid file /var/lib/mysql/k0.pid ended
/home/l/.nix-profile/bin/mysqld_safe: line 128: /var/lib/mysql/k0.err: No such file or directory
The attempt to run *mysqld_safe* was taken from the official docs at
http://dev.mysql.com/doc/refman/5.6/en/starting-server.html.
I see that there are several configuration options for MySQL
(services.mysql.*) defined in the NixOS manual
(https://nixos.org/nixos/manual/options.html#opt-services.mysql.enable)
but this seems to be for enabling it as a service that starts
unconditionally on every boot (configuration.nix), which I want to avoid.
How do I start MySQL without touching configuration.nix? If
configuration.nix is the only sane/preferred way to use MySQL on NixOS,
then is there a resource/wiki/blogpost that discusses a minimal example?
I don't mind trial-and-error with editing my system configs but seeing a
second-hand account of the entire process would be very helpful.
Please forgive me if I have missed any obvious documentation.
Best,
Linus
More information about the nix-dev
mailing list