WSL Ubuntu 安装mysql 问题

1,629 阅读1分钟

case:

sudo service mysql start

tips follow:

Starting MySQL database server mysqld 
No directory, logging in with HOME=/
mkdir: cannot create directory ‘//.cache’: Permission denied
-su: 19: /etc/profile.d/wsl-integration.sh: cannot create //.cache/wslu/integration: Directory nonexistent

提示没有权限,文件目录不存在,具体原因还未去细看,以下是解决贴

1.cat /etc/passwd | grep mysql

mysql:x:111:115:MySQL Server,,,:/nonexistent:/bin/false

2.sudo usermod -d /var/lib/mysql mysql

3.cat /etc/passwd | grep mysql

root:x:1000:1000:,,,:/var/lib/mysql:/bin/bash

4.sudo service mysql start

OK

ps: 如果遇到mysql用户处于precess,

usermod: user mysql is currently used by process 82

使用 ps -ef|grep mysql 找出mysql相关的服务进程 kill掉就行了