WSL2支持systemd和GUI,如何管理mariaDB

WSL2的preview版本开始支持systemd了,我没有安装应用商店的WSL,需要去Releases · microsoft/WSL · GitHub 下载 msixbundle文件,双击安装更新。

wsl.exe --update --web-download

echo -e "[boot]\nsystemd=true" | sudo tee -a /etc/wsl.conf
配置后需要通过wsl --shutdown命令关闭wsl,来进行wsl的完整重启。

判断wsl是否已启用systemd,可通过以下命令查看:

ps --no-headers -o comm 1

通过systemctl的list-units、list-unit-files命令,都可以很好的查看目前的systemd状态,命令如下:
systemctl list-units --type=service
systemctl list-unit-files --type=service --state=enabled

试一下管理mariaDB

$ sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
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

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

 然后:
sudo systemctl start mariadb
 

运行 Linux GUI 应用

https://learn.microsoft.com/zh-cn/windows/wsl/tutorials/gui-apps

 启动GUI程序出现报错 cannot open display 的解决办法:

export DISPLAY=:0
sudo rm -rf /tmp/.X11-unix
ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

 xrdp + i3wm

  

 

posted @ 2022-11-11 10:22  shankun  阅读(204)  评论(0编辑  收藏  举报