WhitewaterFoundry / Pengwin

A Linux distro optimized for WSL based on Debian.
Other
1.48k stars 105 forks source link

Handle multiple users in /etc/profile scripts #394

Open Morgy93 opened 5 years ago

Morgy93 commented 5 years ago

Describe the bug Trying to start mysql service I end up with some weird error.

To Reproduce Steps to reproduce the behavior:

  1. sudo apt install mysql-server
  2. sudo service mysql start
  3. See error

Expected behavior I expect the mysql to start

Additional context

morgy@dev:/$ sudo service mysql start
[....] Starting MySQL database server: mysqldsu: warning: cannot change directory to /nonexistent: No such file or directory
Welcome to Pengwin. Type 'pengwin-setup' to run the setup tool. You will only see this message on the first run
touch: cannot touch '/nonexistent/.firstrun': No such file or directory
-sh: 22: /etc/profile.d/00-pengwin.sh: Syntax error: "(" unexpected

I only reported it here because of the profile stuff provided by pengwin - not sure if that is the cause.

Basic Troubleshooting Checklist

[X] I have searched Google for the error message. [X] I have checked official WSL troubleshooting documentation: https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#confirm-wsl-is-enabled. [X] I have searched the official Microsoft WSL issues page: https://github.com/Microsoft/WSL/issues. [X] I have searched the Pengwin issues page: https://github.com/WhitewaterFoundry/Pengwin/issues. [ ] I have reset Pengwin: Settings->Apps->Apps & features->Pengwin->Advanced Options->Reset. [ ] I have disabled and re-enabled WSL in Windows Features. [X] I have run Windows 10 updates and restarted.

What other troubleshooting have you attempted?

Insert here: [X] reinstalled mysql-server

Pengwin Version

Find: Settings->Apps->Apps & features->Pengwin->Advanced Options->Version.

Insert here: 1.2.1.0

Windows Build

Run 'systeminfo | findstr /C:"OS"' in Command Prompt and insert here: image Does not seem to work with other languages than English. You probably rather want to know: Windows 10 Pro v1809 (build 17763.437)

For help on retrieving: https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#check-your-build-number

crramirez commented 5 years ago

Ok, this /nonexistent look very strange. Have you tried restarting Windows? I will make some tests from my side.

Morgy93 commented 5 years ago

Yes I did restart Windows - no change. I already purged the whole mysql installation and reinstalled but it's not able to start during installation.

The error just looks weird by the way, acually it has problems with su

Running service mysql start it asks for a password (which is not my sudo password and I don't have another one [empty password also doesn't work]) and then it is failing of course. But in my understanding su doesn't work in WSL anyway.

morgy@dev:/$ service mysql start
[....] Starting MySQL database server: mysqldPassword:
su: Authentication failure

I really have no clue what is going on here - help would be very much appreciated.

Morgy93 commented 5 years ago

Well, I found some workaround to get the mysql server running: sudo mysqld

morgy@dev:/$ sudo service mysql status
[info] /usr/bin/mysqladmin  Ver 8.42 Distrib 5.7.25, for Linux on x86_64
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version          5.7.25-1
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 12 min 16 sec

Threads: 1  Questions: 12  Slow queries: 0  Opens: 106  Flush tables: 1  Open tables: 99  Queries per second avg: 0.016.

I'll have a look if I can work with this, but of course I'd be more than happy to work out a proper solution.

crramirez commented 5 years ago

To inform you I reproduced the issue so, I will take a look.

crramirez commented 5 years ago

Ok, the problem is that mysqld is logging with the user mysql and is trying to execute /etc/profile with sh. This needs a lot of fixes from our side. Meanwhile, as a workaround start mysql with:

sudo mv /etc/profile /etc/profile_ && sudo service mysql start; sudo mv /etc/profile_ /etc/profile

We will keep posting fixes info here.

Regards

sirredbeard commented 5 years ago

I am glad we were able to find a workaround to get MySQL working. We will look at changes we can make to support MySQL better going forward. Sorry for the frustration.

sirredbeard commented 5 years ago

Patching incoming. https://github.com/WhitewaterFoundry/pengwin-setup/pull/124

jimmerk commented 4 years ago

I'm having this same problem ... Pretty sure this started when I installed Docker Desktop, but I've since uninstalled it.

$sudo service mysql start Starting MySQL database server: mysqldsu: warning: cannot change directory to /nonexistent: No such file or directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!

in Windows 10 version 2004 build 19041.153

crramirez commented 4 years ago

Hello.

This should not be happening anymore but with the recent changes to support WSL2 it could be resurrected. We will make some tests.

Meanwhile use the workaround that is described in above.

Regards, Carlos

jimmerk commented 4 years ago

Thanks for your response. I found that if I replaced the /nonexistant path in the /etc/passwd file with /var/lib/mysql, starting mysql worked fine. Is there any negative to leaving it that way?

flokirr commented 4 years ago

I can confirm this is happening in WSL2 windows build 2004.

Trying the solution above did not help me (temporarely removing the profile).

I tried completely purging mysql from the distro and reinstalling but to no effect.

@jimmerk solution did not help me either.

Imagine being hyped for WSL2 for like a, year? and be completely disappointed over my 0 productivity evening.

Edit: After restarting the machine entirely the mysql service started successfully. Time to restore my previous db state. Not sure which fix fixed it.

crramirez commented 4 years ago

Sometimes WSL2 get stuck. We still don't know why. Usually with the command wsl.exe --shutdown is enough to restore WSL2 to its regular state.

hansbothe commented 4 years ago

Thanks for your response. I found that if I replaced the /nonexistant path in the /etc/passwd file with /var/lib/mysql, starting mysql worked fine. Is there any negative to leaving it that way?

sudo usermod -d /var/lib/mysql mysql

works for me

jsvptf22 commented 3 years ago

I'm having this same problem ... Pretty sure this started when I installed Docker Desktop, but I've since uninstalled it.

$sudo service mysql start Starting MySQL database server: mysqldsu: warning: cannot change directory to /nonexistent: No such file or directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!

in Windows 10 version 2004 build 19041.153

THE PROBLEM WAS DOCKER DESKTOP