我正在尝试在我的wslUbuntu 18.04上重新安装mysql服务器
(我在Windows10上有MySQL服务器,但在3307端口上。我不知道这是否重要,但以防万一!(
我既不能sudo service mysql start
也不能sudo /etc/init.d/mysql start
,它返回
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 [Failed]
我在谷歌上搜索了关于在Ubuntu中重新安装mysql的信息,并遵循了以下步骤
-https://github.com/microsoft/WSL/issues/1761
sudo su
apt-get remove --purge 'mysql*'
apt-get autoremove
apt-get autoclean
rm -f /etc/mysql /var/lib/mysql
apt-get install mysql-server
但在尝试apt-get install mysql-server
时,我得到了以下错误。
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ]
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Cannot open /proc/net/unix: No such file or directory
Cannot stat file /proc/1/fd/5: Operation not permitted
Cannot stat file /proc/1/fd/10: Operation not permitted
Cannot stat file /proc/1/fd/6: Operation not permitted
Cannot stat file /proc/5/fd/7: Operation not permitted
Cannot stat file /proc/5/fd/10: Operation not permitted
Cannot stat file /proc/5/fd/5: Operation not permitted
Cannot stat file /proc/843/fd/7: Operation not permitted
Cannot stat file /proc/843/fd/10: Operation not permitted
Cannot stat file /proc/843/fd/5: Operation not permitted
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
我一直在谷歌上搜索Cannot open /proc/net/unix: No such file or directory
和invoke-rc.d: could not determine current runlevel
问题,但找不到正确的解决方案。
如果你能在这方面给我一些建议,我真的很感激。谢谢
当我查看日志文件/var/log/mysql/error.log
时,我发现了
[ERROR] [MY-012585] [InnoDB] Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB.
我通过创建一个新的配置文件/etc/mysql/conf.d/no_native_aio.conf
:禁用了本机AIO的使用
[mysqld]
innodb_use_native_aio = 0
然后我可以像这样启动数据库服务器:
sudo service mysql start
我还必须运行
sudo mysql_secure_installation
以设置root用户的密码。
我不得不欺骗dpkg
,让它相信postinstall脚本已经运行成功通过:
- 添加
exit 0
作为/var/lib/dpkg/info/mysql-server-8.0.postinst
中的第二行 - 运行
sudo dpkg --configure -a
- 从
/var/lib/dpkg/info/mysql-server-8.0.postinst
中删除exit 0
这将是WSL1与WSL2的问题。/proc
目录未完全填充WSL1。要检查您的版本,请运行(从powershell(wsl -l -v
。如果它没有给你任何版本信息,那么你就在WSL1上。