MySql数据与MariaDb有冲突,升级之前需先卸载MariaDb。
#rpm -qa | grep mariadb
......
#rpm -e mariadb-libs-*.*.**-*.el7.x86_64 --nodeps
......
#rpm -qa | grep mariadb
......
1 下载MySql
使用浏览器访问MySQL下载页面:
注意:Operating System 需要选择Linux,OS Version需要选择Linux 7。这样才可以与CentOS 7相互对应。如果选择不正确的安装包,则会导致各种奇怪的问题。
选择下载RPM Bundle:mysql-8.0.32-1.el7.x86_64.rpm-bundle.tar。其中el7表明该数据包对应Linux 7.x系统。
2 安装MySQL
将下载的数据包,上传至服务器的/usr/local/src目录下。
解压缩数据包:
#cd /usr/local/src
......
#tar xf mysql-8.0.32-1.el7.x86_64.rpm
......
#ls
mysql-community-client-8.0.32-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.32-1.el7.x86_64.rpm
mysql-community-common-8.0.32-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.32-1.el7.x86_64.rpm
mysql-community-devel-8.0.32-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.32-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.32-1.el7.x86_64.rpm
mysql-community-libs-8.0.32-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.32-1.el7.x86_64.rpm
mysql-community-libs-server-8.0.32-1.el7.x86_64.rpm
mysql-community-libs-server-debug-8.0.32-1.el7.x86_64.rpm
mysql-community-test-8.0.32-1.el7.x86_64.rpm
......
按照如下顺序执行安装过程。
安装common:
#rpm -ivh mysql-community-common-8.0.32-1.el7.x86_64.rpm --nodeps --force
......
安装libs:
#rpm -ivh mysql-libs-8.0.32-1.el7.x86_64.rpm --nodeps --force
......
安装libs-compat:
#rpm -ivh mysql-libs-compat-8.0.32-1.el7.x86_64.rpm --nodeps --force
......
安装client:
#rpm -ivh mysql-client-8.0.32-1.el7.x86_64.rpm --nodeps --force ......
安装server:
#rpm -ivh mysql-server-8.0.32-1.el7.x86_64.rpm --nodeps --force ......
3 配置MySql
初始化mysql:
#mysqld --initialize
......
配置服务:
#chown mysql.mysql /var/lib/mysql -R
......
#systemctl start mysqld.service
......
#systemctl enable mysqld
......
查看初始密码:
#cat /var/log/mysqld.log | grep password
......
修改初始密码:
#mysql -u root -p
Enter password:
......
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
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>ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY '****************';
......
mysql>exit;
退出后,然后使用新密码重新登陆。如果可以顺利登陆,则证明密码修改成功。
检查本版号:
# mysql --version
mysql Ver 8.0.32 for Linux on x86_64 (MySQL Community Server - GPL)
# mysqld --version
/usr/sbin/mysqld Ver 8.0.32 for Linux on x86_64 (MySQL Community Server - GPL)
至此,MySql安装升级完成。