打算做个网站,学着安装mysql。网上查了一些教程,最后找到官网教程以及另一个教程,互为参照。我采用APT库安装方式,步骤如下:
- 在
https://dev.mysql.com/downloads/repo/apt/
下载.deb
包并安装,出来图形界面直接默认选ok就行
$ sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
- 更新
$ sudo apt update
如果出现以下关于签名的问题
......
Err:5 http://repo.mysql.com/apt/ubuntu bionic InRelease
The following signatures were invalid: EXPKEYSIG 8C718D3B5072E1F5 MySQL Release Engineering <mysql-build@oss.oracle.com>
Get:8 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease [88.7 kB]
Hit:9 http://packages.microsoft.com/repos/vscode stable InRelease
Reading package lists... Done
W: GPG error: http://repo.mysql.com/apt/ubuntu bionic InRelease: The following signatures were invalid: EXPKEYSIG 8C718D3B5072E1F5 MySQL Release Engineering <mysql-build@oss.oracle.com>
E: The repository 'http://repo.mysql.com/apt/ubuntu bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
参考https://serverok.in/mysql-8-apt-error-the-following-signatures-were-invalid
,注意要加sudo
$ sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8C718D3B5072E1F5
- 安装mysql
$ sudo apt-get install mysql-server
要求设密码建议直接设成password
谨防忘记
4. 查看状态,mysql会在安装后自动启动
$ sudo service mysql status
出现一下内容表示正常
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: active (running) since Mon 2019-09-09 19:34:14 CST; 16min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 870 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=e
Main PID: 937 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 4915)
CGroup: /system.slice/mysql.service
└─937 /usr/sbin/mysqld
Sep 09 19:34:12 LoveBin systemd[1]: Starting MySQL Community Server...
Sep 09 19:34:14 LoveBin systemd[1]: Started MySQL Community Server.
关闭
$ sudo service mysql stop
重启
$ sudo service mysql start
到此差不多顺利安装完,后续的事后续再说