首页 > 数据库技术 > 详细

WSL2 配置及ubuntu18.04安装mysql8.0+

时间:2020-09-21 16:43:12      阅读:355      评论:0      收藏:0      [点我收藏+]

wsl2 完整配置

参考将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

  1. 下载mysql.server.sh启动脚本

wget https://raw.githubusercontent.com/mysql/mysql-server/8.0/support-files/mysql.server.sh

  1. 修改该文件并复制到/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

  1. 启动MySQL

sudo service mysql start

sudo service mysql stop

忘记mysql8.0 root 密码,如何重置

官网文档:B.3.3.2.3 Resetting the Root Password: Generic Instructions

参考: MySQL8.0 忘记 root 密码下如何修改密码

  1. 关闭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
  1. 重启mysql服务

sudo service mysql start

  1. 键入mysql进入mysql命令行

刷新权限表

flush privileges;

  1. 查看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‘;

  1. 删除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

WSL2 配置及ubuntu18.04安装mysql8.0+

原文:https://www.cnblogs.com/panlq/p/13704965.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!