Dmi*_*riy 5 mysql ubuntu windows-subsystem-for-linux
我刚刚安装了 WSL Ubuntu 20.04,我做的第一件事就是
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server
Run Code Online (Sandbox Code Playgroud)
它给了我什么
Setting up mysql-server-8.0 (8.0.20-0ubuntu0.20.04.1) ...
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/42/fd/7: Operation not permitted
Cannot stat file /proc/42/fd/10: Operation not permitted
Cannot stat file /proc/42/fd/5: Operation not permitted
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 3726
sleep: cannot read realtime clock: Invalid argument
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Run Code Online (Sandbox Code Playgroud)
和
dpkg:依赖问题阻止了 mysql-server 的配置:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Setting up libcgi-pm-perl (4.46-1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Setting up libhtml-template-perl (2.97-1) ...
Setting up libcgi-fast-perl (1:2.15-1) ...
Processing triggers for systemd (245.4-4ubuntu3.1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)
然后我试过了 sudo mysql_secure_installation
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
这不仅在 WSL 上。
我和你有同样的问题;Ubuntu 20.04 WSL我在Windows 10中使用了以下版本,它对我有帮助。首先,由于dependency problems - leaving unconfigured错误,我按照这里的答案清除MySQL并尝试重新安装:
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
sudo apt-get install mysql-server
Run Code Online (Sandbox Code Playgroud)
完成此操作后,问题仍然存在(但无论如何这肯定是有帮助的)。
下一个线索是Can't connect to local MySQL server through socket错误... MySQL命令要求输入密码并提供错误的密码会导致此错误。密码还没设置吧?错误的!阅读MySQL 8.0 参考手册 - 默认权限安装最初会设置一个随机密码。所以必须先更改root密码。
为此,我遵循了这个答案。为了方便起见,我将答案复制在这里:
在 ubuntu 上我做了以下操作:
sudo service mysql stop
sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking
Run Code Online (Sandbox Code Playgroud)
然后在新终端中运行 mysql:
mysql -u root
Run Code Online (Sandbox Code Playgroud)
并运行以下查询来更改密码:
UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;
Run Code Online (Sandbox Code Playgroud)
在 MySQL 5.7 中,mysql.user 表字段中的密码字段被删除,现在字段名称为“authentication_string”。
引用答案后,请注意该PASSWORD()函数已被弃用,如在此答案中共享的那样。正如那里所述,只需使用我使用过的任何MySQL 加密函数MD5()替换它即可。
最后:
sudo service mysql start
* Starting MySQL database server mysqld [ OK ]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8671 次 |
| 最近记录: |