一、前言
本文主要是在前文的基础上进一步研究。
(超详细)基于nginx、gunicorn、flask:部署阿里云服务器,前文中的细节不在本文赘述。
本文主要结构是:
- 安装mysql;
- 操作数据库;
- 数据库云端访问;
- 通过request远程访问测试;
二、停止gunicorn服务
输入以下命令停止所有的gunicorn进程,方便后续调试:
kill -9 9479
三、安装mysql
1. 设置下载源
无法直接使用yum安装mysql,需要使用wget拉取下载源:
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
添加下载源:
sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
安装yum工具
sudo yum install -y yum-utils
2. 安装mysql
使用代码安装
sudo yum install -y mysql-community-server
如果出现以下问题,
The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-server-8.0.34-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
则去掉GPG检查:
sudo yum -y install mysql-community-server --nogpgcheck
启动mysql服务:
sudo service mysqld start
3. 初始化mysql
查看初始密码
sudo grep 'temporary password' /var/log/mysqld.log
使用初始密码登录:
mysql -u root -p
成功之后重新设置新密码:
ALTER USER 'root'@'localhost' IDENTI