文章目录
部署环境
操作系统:CentOS Linux release 7.5.1804 (Core)
MYSQL版本:mysql-5.7.30-1
下载RPM安装包
下载地址
对应组件下载
-
可选择 rpm-bundle.tar下载,下载后解压
tar xf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
-
细化下载需要的mysql组件,有(server、client、common、libs)
(mysql-community-server-5.7.30-1.el7.x86_64.rpm
mysql-community-client-5.7.30-1.el7.x86_64.rpm
mysql-community-common-5.7.30-1.el7.x86_64.rpm
mysql-community-libs-5.7.30-1.el7.x86_64.rpm
卸载旧版本Mysql
卸载mysql
yum remove `rpm -qa|grep mysql`
卸载mariadb
yum remove `rpm -qa|grep mariadb`
安装Mysql组件
rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm mysql-community-client-5.7.30-1.el7.x86_64.rpm mysql-community-libs-5.7.30-1.el7.x86_64.rpm mysql-community-common-5.7.30-1.el7.x86_64.rpm --force --nodeps
个别服务器安装时报错
在阿里云ESC服务器上安装mysql5.7时报错如下: [root@boke mysql]# rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm mysql-community-client-5.7.30-1.el7.x86_64.rpm mysql-community-libs-5.7.30-1.el7.x86_64.rpm mysql-community-common-5.7.30-1.el7.x86_64.rpm warning: mysql-community-server-5.7.30-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error: Failed dependencies: libaio.so.1()(64bit) is needed by mysql-community-server-5.7.30-1.el7.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.30-1.el7.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.30-1.el7.x86_64 原因:Mysql依赖libaio,当前服务器上没libaio库 解决办法:yum -y install libaio 安装成功后,重新安装一遍mysql
登录并修改mysql密码
启动mysql
systemctl start mysqld 启动mysql systemctl status mysqld 查看mysql状态 systemctl stop mysqld 关闭mysql
ps -ef|grep mysql 查看mysql进程 netstat -ntpl|grep 3306 查看3306端口
登录mysql
查找mysql临时密码 [root@localhost opt]# grep 'temporary password' /var/log/mysqld.log 2020-05-07T07:20:00.475125Z 1 [Note] A temporary password is generated for root@localhost: cK0N45(p+o:p cK0N45(p+o:p ##登录随机密码 [root@localhost opt]# mysql -uroot -p Enter password: ##这里输入密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.30 Copyright (c) 2000, 2020, 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> alter user user() identified by 'Ll@123456'; Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)