win10子系统ubuntu 18.04安装mariadb

变更apt源

由于国外的源比较慢,所以先变更源为清华源

  1. 备份原有的文件
    mv /etc/apt/sources.list /etc/apt/sources.list.bak
  2. 创建sources.list并添加清华的源
    touch /etc/apt/sources.list
    vim /etc/apt/sources.list
    在sources.list中添加如下源
deb 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 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 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

  1. apt源更新
    apt update

安装mariadb

1.执行命令sudo apt-get install mariadb-server安装
2.安装完成后启动mariadb
这里跟一般的18.04系统会有差别,由于是win10的子系统,如果直接敲systemctl start mariadb无法成功,会有如下报错:
System has not been booted with systemd as init system (PID 1). Can't operate.
所以需要使用老的命令service mysql restart
3.完成上一步后,使用如下命令,完成mariadb的初始化安装
mysql_secure_installation
。默认root密码的输入

Enter current password for root (enter for none):
OK, successfully used password, moving on...

这里由于是初始安装,所以是没有密码,敲击回车即可
剩余的步骤就是一路安装提示来即可。

你可能感兴趣的:(win10子系统ubuntu 18.04安装mariadb)