安装 Mariadb

更新指定版本

创建并编辑:vim /etc/yum.repos.d/mariadb.repo

  1. [mariadb]
  2. name = MariaDB
  3. baseurl = http://yum.mariadb.org/10.3.4/centos74-amd64/
  4. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  5. gpgcheck=1

MySQL 安装 - 图1

备份数据库和重要配置文件

备份数据库 mysqldump -u root -p —all-databases > /home/gao/db/alldb.sql

备份配置文件 cp /etc/my.cnf /etc/my.cnf.bak

升级后维护

升级

# 停止服务
systemctl stop mariadb
# 升级安装
yum install mariadb-server
# 启用服务
systemctl start mariadb

这时候远程访问时可能会报出如下错误;

Error loading schema content Error Code: 1558 Column count of mysql.proc is wrong. Expected 21, found 20. Created with MariaDB 50560, now running 100304. Please use mysql_upgrade to fix this error

解决方法

mysql_upgrade -ugaox -p

现在就可正确访问了

cankao :

MySQL 安装 - 图2

MySQL 数据库

1. 下载安装包

从官网下载:

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar

MySQL 安装 - 图3

2. 解压文件

MySQL 安装 - 图4

tar -xvf mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar

文件结构如下:
MySQL 安装 - 图5

必须的四个文件

mysql-community-common-5.7.24-1.el7.x86_64.rpm 
mysql-community-libs-5.7.24-1.el7.x86_64.rpm
mysql-community-client-5.7.24-1.el7.x86_64.rpm 
mysql-community-server-5.7.24-1.el7.x86_64.rpm

安装过程:

rpm -ivh mysql-community-common-5.7.24-1.el7.x86_64.rpm

依赖错误解决

安装第二、第四个时依赖错误的解决办法

解决第二个错误依赖:yum remove mysql-libs

yum remove mysql-libs

四、 yum install libaio.x86_64

rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm

warning: mysql-community-server-5.7.24-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYerror: Failed dependencies: libaio.so.1()(64bit) is needed by mysql-community-server-5.7.24-1.el7.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.24-1.el7.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.24-1.el7.x86_64

解决


yum install libaio.x86_64

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies —> Running transaction check —-> Package libaio.x86_64 0:0.3.109-13.el7 will be installed —> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================

Package Arch Version Repository Size

Installing: libaio x86_64 0.3.109-13.el7 base 24 k

Transaction Summary

Install 1 Package

Total download size: 24 k Installed size: 38 k Is this ok [y/d/N]: y Downloading packages: libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : libaio-0.3.109-13.el7.x86_64 1/1 Verifying : libaio-0.3.109-13.el7.x86_64 1/1

Installed: libaio.x86_64 0:0.3.109-13.el7

Complete!

3. 初始化数据库

mysqld --initialize