I'm on WSL2 Ubuntu and trying to setup the environment for a Laravel app. I encountered a problem trying to install mysql. I used homebrew to install it and when I try to run it with brew services start mysql
, I get this error:
Failed to connect to bus: No medium found
Error: Failure while executing; `/home/linuxbrew/.linuxbrew/bin/systemctl --user daemon-reload` exited with 1.
I tried to find someone with the same problem but I seem to be the only one. Any advice?
CodePudding user response:
I tried to find someone with the same problem but I seem to be the only one.
It's likely that not many people have tried to use Brew to install MySQL on Ubuntu in WSL ;-). The typical process would be to install via apt
, which will give you the compatible (but non-Oracle) MariaDB version, mapped to MySQL commands.
If you need the "official" MySQL or a later version than is available in the Ubuntu repositories, then you can install from the official .deb
package as detailed here (and many other guides).
As for your actual problem ...
I haven't actually used Brew, but I installed it in one of my "throwaway" Ubuntu instances in WSL to confirm my hunch. As I expected, as part of the installation for MySQL, Brew installs (a second copy of) Systemd into the Brew directory as a MySQL dependency. And yes, I could reproduce the error message -- and it's not unexpected.
WSL is not (easily) compatible with Systemd, as detailed in a number of other questions here on Stack Overflow (and elsewhere). I'll point you to one of my answers on Ask Ubuntu.
You probably aren't going to be able to easily change the method that Brew is attempting to use to start MySQL, so my recommendation would be to use the stock Ubuntu packages.
Note that the official .deb
may (I haven't tested) also attempt to use Systemd.
The nice thing about the Ubuntu package is that it provides an "old style" SysVInit script that will allow you to startup via sudo service mysql start
, which will work on WSL.
You can likely also start by executing the MySQL daemon directly, with the proper command-line and configuration in place. Both the SysVInit script and Systemd unit files will do this automatically, but it's possible (as I detail in that other answer) to set things up manually as well.