wsl2 完整配置
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
raw.githubusercontent.com 被牆解決方案
修改hosts
sudo vi /etc/hosts
199.232.4.133 raw.githubusercontent.com
ws2 ubuntu18.04安裝mysql8.0+
1.下載最新的deb文件
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
2. 解壓包
sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
安裝過程中提示選擇安裝版本,默認安裝的就是8.0版本,所以直接選擇“OK”確認即可
3. 執行安裝
sudo apt update
4. 安裝mysql8.0 server
sudo apt install mysql-server
安裝過程中會提示設置root密碼。按照提示輸入即可
輸入之后會出現選擇加密方式的提示界面,我在網上的教程中看到默認的mysql8.0的加密方式與ubuntu18.04 不兼容,所以選擇5.x的加密方式;建議選擇下邊的那個
·Use Legacy Authentication Method·
5. 驗證安裝,輸入命令
mysql -u root -p
錯誤記錄
1. 簽名無效 NO_PUBKEY xxxxxxxxxxxxxx
解決方式,設置可以並重新執行第三步命令
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 報錯的key
eg:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
2. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
解決方案: INSTALLING MYSQL 8.0 UNDER WSL 2 AND UBUNTU
- 下載mysql.server.sh啟動腳本
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
- 啟動MySQL
sudo service mysql start
sudo service mysql stop
The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
運行 sudo service mysql start
出現如上報錯.
- 如果該目錄不存在則創建
/var/run/mysqld
- 創建文件
touch mysqld.pid
chmod -R 777 /var/run/mysql
- 重啟服務:
sudo service mysql start
忘記mysql8.0 root 密碼,如何重置
官網文檔:B.3.3.2.3 Resetting the Root Password: Generic Instructions
參考: MySQL8.0 忘記 root 密碼下如何修改密碼
- 關閉mysql服務,使用
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
- 重啟mysql服務
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鏡像
linux
~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
windows
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
wsl some issue
WSL2 Input/output error
解決方案1
wsl --shutdown
wsl
解決方案2: 重新掛載
sudo umount /mnt/c
sudo mount -t drvfs C:\\ /mnt/c