Win10 Linux子系统安装MySQL
1. 系统环境:
Win10 1809
子系统 Ubuntu 20.04LTS
2.安装过程:
1.更换为国内源
sudo chmod 777 /etc/apt/sources.list
sudo vim /etc/apt/sources.list
(子系统中内置了vim,如果没有的话就sudo-apt-get install vim)
将原有的源全部注释掉,添加以下源:
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
更换完成之后,保存并刷新软件资源sudo apt-get update
2.安装
sudo apt-get install mysql-server-5.7
如果碰到如下问题:
dpkg returned an error code (1)
则执行
cd /var/lib/dpkg
sudo mv info info.baksudo
mkdir info
然后在重新sudo apt-get install mysql-server-5.7就ok了
3.使用
(注意:子系统与windows共用端口,有可能出现因为端口占用导致服务启动失败)
最好先停用win10上的mysqlserver,否则linux端可能启动不成功,会报错
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
感谢这位大哥的博客提醒,
如果这样做之后还是报这个错误,则执行 sudo /etc/init.d/mysql start,也可以启动mysql
然后sudo service mysql start 启动mysql服务
之后 sudo mysql_secure_installation ,设置密码,具体操作请看 这里,同样非常感谢这位博主
设置完成密码后直接mysql -u root -p然后输入密码就成功了
标签:restricted,sudo,edu,Linux,Win10,main,multiverse,ubuntu,MySQL
来源: https://blog.csdn.net/qq_26041751/article/details/112757153