Windows子系统安装mysql服务器

时间:2019-02-22 21:35:19

标签: mysql windows-10 windows-subsystem-for-linux

在ubuntu 18.04子系统Windows 10上安装mysql-server。

Cannot open /proc/net/unix: No such file or directory
Cannot stat file /proc/1/fd/5: Operation not permitted
Cannot stat file /proc/3/fd/7: Operation not permitted

请帮助

enter image description here

7 个答案:

答案 0 :(得分:4)

我使用Windows 10下的Ubuntu 18.04作为子系统,因此您必须通过添加MariaDB所需的存储库开始:

sudo apt-get install software-properties-common

然后通过以下方式更新安装:

sudo apt更新

通过以下方式安装MariaDB:

sudo apt安装mariadb-server

系统将提示您设置root密码,并等待安装继续。安装完成后,发出以下命令:

sudo服务mysql启动

就是这样,要检查您的mysql和mariadb版本,请尝试:

mysql --version

答案 1 :(得分:3)

as mentioned a guy at github and it solved my problem 问题出在脚本“ /etc/profile.d/wsl-integration.sh”。作为一种快速的解决方法,在“ /etc/profile.d/wsl-integration.sh”的第一行之前插入以下行(使用sudo编辑文件):

# Check if we have HOME folder
if [ "${HOME}" = "/" ]; then
  return
fi

我的意思是在该行之前:

WSL_INTEGRATION_CACHE=$HOME/.cache/wslu/integration`

答案 2 :(得分:3)

我的MySQL已在本机Windows 10系统上运行。它一定一直在努力争取相同的默认值。我尝试关闭本机MySQL,然后使用WSL安装,但工作正常。

答案 3 :(得分:1)

我不知道有多少人遇到这个问题,但是对我有用的是结合执行以下步骤:

https://github.com/FiveTechSoft/mod_harbour/wiki/Install-MySQL-server-on-Windows-10-bash

并确保更改WSL上MySQL服务器的端口。我在Windows上运行MySQL服务器实例3306,它阻止了WSL实例启动。

您可以只编辑配置文件:

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

并将端口部分更新为您喜欢的其他任何内容。

祝你好运

答案 4 :(得分:0)

对于遇到此问题的任何人,请关闭并重新打开WSL,然后运行 sudo服务mysql启动 sudo dpkg-配置-a 它应该完成。

答案 5 :(得分:0)

我也不能在wsl上安装mysql(mysql 5.7.30,ubuntu 18.04,win10 1909),所以这里有解决方法。在Windows上安装并运行mysql,然后使用以下命令从ubuntu bash连接它:

mysql -u root -p --host=127.0.0.1 --port=3306 --protocol=TCP

还需要在您的项目设置中配置数据库。不要使用本地主机,我的电脑上的端口是3306,可能与您的不同。希望他们可以在wsl2上修复它。

答案 6 :(得分:0)

我遇到保存问题。原因是您在本地操作系统Win10上安装了MySQL服务器。解决方法:

  1. 转到Windows服务,停止MySQL服务。

  2. 在MySQL服务器文件夹下修改my.ini,我的是C:\Program Files\MySQL\MySQL Server 5.5

    [mysqld]
    \# The TCP/IP Port the MySQL Server will listen on
    port=3306 -> 3308 or other
    
  3. 重新启动您的wsl实例。

  4. 使用root帐户重新安装MySQL服务器

    apt install mysql-server
    service mysql start
    mysql_secure_installation