mySql AWS Lightsail 上的 5.7 安装问题 Linux

mySql 5.7 Installation Issue on AWS Lightsail Linux

我正在尝试在 AWS Lightsail Amazon Linux 上安装 MySQL 5.7,但遇到错误。 它是位于悉尼 A 区的最新 VM,仅 OS(Linux / Unix 蓝图)。我不想将每个安装的 LAMP 与 mysql 一起使用。

我已按照以下步骤操作。

首先,我安装了最新的更新。

sudo yum update -y

输出

Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package ec2-net-utils.noarch 0:0.5-3.36.amzn1 will be updated
---> Package ec2-net-utils.noarch 0:0.6-1.1.amzn1 will be an update
---> Package ec2-utils.noarch 0:0.5-3.36.amzn1 will be updated
---> Package ec2-utils.noarch 0:0.6-1.1.amzn1 will be an update
---> Package kernel.x86_64 0:4.14.165-102.185.amzn1 will be installed
---> Package python27-pip.noarch 0:9.0.3-1.26.amzn1 will be updated
---> Package python27-pip.noarch 0:9.0.3-1.27.amzn1 will be an update
---> Package sudo.x86_64 0:1.8.6p3-29.28.amzn1 will be updated
---> Package sudo.x86_64 0:1.8.6p3-29.29.amzn1 will be an update
--> Finished Dependency Resolution

当我尝试使用 yum 安装 mysql 时,它默认显示 MySQL 5.5

============================================================================================================================================
 Package                          Arch                       Version                                 Repository                        Size
============================================================================================================================================
Installing:
 mysql                            noarch                     5.5-1.6.amzn1                           amzn-main                        2.7 k
Installing for dependencies:
 mysql-config                     x86_64                     5.5.62-1.23.amzn1                       amzn-updates                      49 k
 mysql55                          x86_64                     5.5.62-1.23.amzn1                       amzn-updates                     7.5 M
 mysql55-libs                     x86_64                     5.5.62-1.23.amzn1                       amzn-updates                     816 k
Transaction Summary
============================================================================================================================================

yum info mysql 显示 5.5 版本

sudo yum info mysql

Loaded plugins: priorities, update-motd, upgrade-helper
Available Packages
Name        : mysql
Arch        : noarch
Version     : 5.5
Release     : 1.6.amzn1
Size        : 2.7 k
Repo        : amzn-main/latest
Summary     : MySQL meta package
URL         : http://www.mysql.com
License     : GPLv2 with exceptions
Description : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
            : client/server implementation consisting of a server daemon (mysqld)
            : and many different client programs and libraries. The base package
            : contains the standard MySQL client programs and generic MySQL files.

然后我下载并尝试从 rpm 安装 MySQL 5.7。

sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm

输出

Dependencies Resolved

============================================================================================================================================
 Package                                Arch                Version             Repository                                             Size
============================================================================================================================================
Installing:
 mysql57-community-release              noarch              el7-11              /mysql57-community-release-el7-11.noarch               31 k

Transaction Summary
============================================================================================================================================

Installed:
  mysql57-community-release.noarch 0:el7-11

Repo 已安装,但当我尝试安装时 mysql-community-server,它显示依赖项错误。

sudo yum install mysql-community-server

输出

31 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.29-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.29-1.el7 for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: systemd for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: systemd for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: libsasl2.so.3()(64bit) for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.29-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.29-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.29-1.el7 will be installed
---> Package mysql-community-server.x86_64 0:5.7.29-1.el7 will be installed
--> Processing Dependency: systemd for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: systemd for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: libsasl2.so.3()(64bit) for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.29-1.el7 will be installed
---> Package mysql-community-server.x86_64 0:5.7.29-1.el7 will be installed
--> Processing Dependency: systemd for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: systemd for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Processing Dependency: libsasl2.so.3()(64bit) for package: mysql-community-server-5.7.29-1.el7.x86_64
--> Finished Dependency Resolution
Error: Package: mysql-community-server-5.7.29-1.el7.x86_64 (mysql57-community)
           Requires: systemd
Error: Package: mysql-community-server-5.7.29-1.el7.x86_64 (mysql57-community)
           Requires: libsasl2.so.3()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

我已经在最新的 Linux2 EC2 AMI 上安装了 MySQL 5.7

我正在通过 SSH 密钥对连接 VM,而 VM 不在 Static LIVE IP 上。请帮助我,看看我错过了什么?

首先你需要了解lightsailLinux和最新的EC2Linux的区别。 最新的 EC2 Linux 实例是 Linux AMI2,而 lightsail Linux 是 Linux AMI1.

您可能会在 lightsailEC2 上看到以下命令的区别。

光帆Linux

猫/etc/os-release

NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

EC2Linux

猫/etc/os-release

NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

您可以按照以下步骤在最新的 lightsail Linux 上安装 Mysql 5.7。问题之一可能是您必须通过安全模式设置密码。 首先删除任何现有的 mysql inslatted 组件(如果有的话)。

然后按照以下步骤安装 mysql 5.7。

sudo yum install mysql57 mysql57-server

见图

启动服务

sudo service mysqld start

使用空密码连接或从 mysql 日志中找到临时密码。

cat /var/log/mysqld.log | grep "temporary password"

如果没有使用空密码连接,并且 mysql 日志中没有临时密码,则在安全模式下设置密码。

这里是设置密码的步骤。

sudo service mysqld stop

无密码启动。

sudo mysqld_safe --skip-grant-tables &


2020-02-08T07:36:00.286533Z mysqld_safe Logging to '/var/log/mysqld.log'.
2020-02-08T07:36:00.305112Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

连接 Mysql Shell

mysql -uroot

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

运行 mysql Shell.

中的命令
use mysql;

update user set authentication_string=PASSWORD("Pass@123") where User='root';

flush privileges;
exit

现在重启服务

sudo service mysqld restart

2020-02-08T07:38:51.498523Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[1]+  Done                    sudo mysqld_safe --skip-grant-tables

现在您可以使用新密码连接了。

mysql -uroot -pPass@123

记得在重启时将服务设置为 auto-start。

sudo chkconfig mysqld on

尽情享受吧!