Installing, this may take a few minutes…
WslRegisterDistribution failed with error: 0x800701bc
Error: 0x800701bc WSL 2 ??? https://aka.ms/wsl2kernel
Press any key to continue…
这是官方的讨论连接https://github.com/microsoft/WSL/issues/5393
这是安装文件下载链接https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
修改hosts
sudo vi /etc/hosts
199.232.4.133 raw.githubusercontent.com
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
安装过程中提示选择安装版本,默认安装的就是8.0版本,所以直接选择“OK”确认即可
sudo apt update
sudo apt install mysql-server
安装过程中会提示设置root密码。按照提示输入即可
输入之后会出现选择加密方式的提示界面,我在网上的教程中看到默认的mysql8.0的加密方式与ubuntu18.04 不兼容,所以选择5.x的加密方式;建议选择下边的那个
·Use Legacy Authentication Method·
mysql -u root -p
解决方式,设置可以并重新执行第三步命令
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 报错的key
eg:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
解决方案: INSTALLING MYSQL 8.0 UNDER WSL 2 AND UBUNTU
wget https://raw.githubusercontent.com/mysql/mysql-server/8.0/support-files/mysql.server.sh
/etc/init.d/
目录下# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=/usr
datadir=/var/lib/mysql
# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# 0 means don‘t wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900
# Lock directory for RedHat / SuSE.
lockdir=‘/var/lock/subsys‘
lock_file_path="$lockdir/mysql"
# The following variables are only set for letting mysql.server find things.
# Set some defaults
mysqld_pid_file_path=/var/run/mysqld/mysqld.pid
if test -z "$basedir"
mv mysql.server.sh /etc/init.d/mysql
chomd +x /etc/init.d/mysql
sudo service mysql start
sudo service mysql stop
官网文档:B.3.3.2.3 Resetting the Root Password: Generic Instructions
参考: MySQL8.0 忘记 root 密码下如何修改密码
skip-grant-tables
跳过权限验证vi /etc/mysql/mysql.conf.d/mysqld.cnf
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
skip-grant-tables
sudo service mysql start
mysql
进入mysql
命令行刷新权限表
flush privileges;
root
用户和密码字段先将密码滞空use mysql;
select host, user, authentication_string, plugin from user;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host | user | authentication_string | plugin
|
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | mysql_native_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
4 rows in set (0.01 sec)
将旧密码滞空
update user set authentication_string=‘‘ where user=‘root‘;
skip-grant-tables
限制,重启mysql
服务,重连mysql
,并重置密码use mysql;
FLUSH PRIVILEGES;
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘MyNewPass‘;
~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
WSL2 配置及ubuntu18.04安装mysql8.0+
原文:https://www.cnblogs.com/panlq/p/13704965.html