文档首页/ 企业上云/ 数据库上云/ 实施步骤/ 数据库迁移/ 在弹性云服务器上安装MySQL
更新时间:2024-06-21 GMT+08:00
分享

在弹性云服务器上安装MySQL

使用root登录刚创建的弹性云服务器,然后进行MySQL安装操作:

  1. 确保服务器系统处于最新状态

    yum -y update

    如果显示以下内容说明已经更新完成

    Replaced:

    grub2.x86_64 1:2.02-0.64.el7.centos grub2-tools.x86_64 1:2.02-0.64.el7.centosComplete!

  2. 重启服务器

    reboot

  3. 首先检查是否已经安装,如果已经安装先删除以前版本,以免安装不成功

    php -v

    rpm -qa | gerp mysql

    yum list installed | grep mysql

    如果显示以下内容说明没有安装服务

    -bash: gerp: command not found

  4. 下载MySQL安装包

    rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

    rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

  5. 安装MySQL

    yum install -y mysql-server

    yum install mysql-community-server

    如果显示以下内容说明安装成功

    Complete!

    如果在安装过程中遇到“The GPG keys listed for the “MySQL 5.7 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.”报错,请先执行:

    rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

    再重新执行本步骤安装命令

  6. 设置开机启动MySQL

    systemctl enable mysqld.service

  7. 检查是否已经安装了开机自动启动

    systemctl list-unit-files | grep mysqld

    如果显示以下内容说明已经完成自动启动安装

    mysqld.service enabled

  8. 设置开启服务

    systemctl start mysqld.service

  9. 查看MySQL默认密码

    grep 'temporary password' /var/log/mysqld.log

  10. 登录MySQL,输入用户名和密码

    mysql -uroot -p

  11. 修改当前用户密码

    mysql>SET PASSWORD = PASSWORD('Abc123!_');

  12. 开启远程登录,授权root远程登录

    mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'a123456!' WITH GRANT OPTION;

  13. 命令立即执行生效

    mysql>flush privileges;

相关文档