赞
踩
https://downloads.mysql.com/archives/community/
1.1 如何选择MySQL版本?
1.1.1 先查询Linux版本
参考文献
# hostnamectl
[root@VM_0_9_centos ~]# hostnamectl
Static hostname: VM_0_9_centos
Icon name: computer-vm
Chassis: vm
Machine ID: --------------------------------
Boot ID: --------------------------------
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.el7.x86_64
Architecture: x86-64
# cat /proc/version
[root@VM_0_9_centos ~]# cat /proc/version
Linux version 3.10.0-862.el7.x86_64
(builder@kbuilder.dev.centos.org)
(gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) )
#1 SMP Fri Apr 20 16:44:24 UTC 2018
1.1.2 选择合适的mysql版本
由上述信息可知,操作的Linux是CentOS Linux 7,64位,Red Hat,在mysql下载页面,就可以如下图选择:
1、rpm package:是某个特定的包,比如server,client,shared lib等
-- 是的,可以单独安装
2、rpm bundle:是该版本所有包的集合
--- 一般是把服务器端要用的都安装上,其他的不带,尤其是开发包
3、Compressed TAR Archive,是源码,必须用源码方式安装。
---- 这个是源码,需要自己编译的,也有编译好,但不是安装包的
如果Linux联网了,就在如图下载按钮上,右键复制链接,然后在Linux中直接下载:
# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
如果没有联网,就先下载到本地,然后再上传到Linux中。
2.1 检查当前系统是否安装有mariadb
rpm -qa | grep mariadb
如果有就卸载掉所有mariadb相关组件
rpm -e mariadb-xxx --nodeps
原因:据说是如果有mariadb,安装mysql会失败(未遇到)
2.2 检查当前系统是否已安装mysql
rpm -qa | grep mysql
如果有就卸载掉已安装的mysql
-- 查询结果样例
qt-mysql-4.8.5-11.el7.x86_64
pcp-pmda-mysql-3.10.6-2.el7.x86_64
akonadi-mysql-1.9.2-4.el7.x86_64
-- 卸载指令样例
rpm -e --nodeps qt-mysql-4.8.5-11.el7.x86_64
rpm -e --nodeps pcp-pmda-mysql-3.10.6-2.el7.x86_64
rpm -e --nodeps akonadi-mysql-1.9.2-4.el7.x86_64
2.3 获取mysql8.0.18安装包
2.3.1 可参考本文章第一点
2.3.2 习惯将软件安装在 /usr/local/软件名
下
2.4 安装mysql8.0.18
2.4.1 解压安装包
tar -xvf mysql-8.0.18-1.el8.x86_64.rpm-bundle.tar
2.4.2 按顺序安装解压后文件
-- 必须安装(注意顺序)
rpm -ivh mysql-community-common-8.0.18-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el8.x86_64.rpm
--非必要安装(注意顺序)
rpm -ivh mysql-community-libs-compat-8.0.18-1.el8.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.18-1.el8.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.18-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-8.0.18-1.el8.x86_64.rpm
2.5 可能出现的问题以及解决办法
出现问题:error: Failed dependencies:libnuma.so.1()(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64 libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64 libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64 解决办法: yum install numactl 出现问题:error: Failed dependencies:pkgconfig(openssl) is needed by mysql-community-devel-8.0.13-1.el7.x86_64 解决办法: yum install openssl-devel.x86_64 openssl.x86_64 -y 出现问题:error: Failed dependencies:perl(Data::Dumper) is needed by mysql-community-test-8.0.13-1.el7.x86_64 解决办法: yum -y install autoconf 出现问题:error: Failed dependencies:perl(JSON) is needed by mysql-community-test-8.0.13-1.el7.x86_64 解决办法: yum install perl.x86_64 perl-devel.x86_64 -y yum install perl-JSON.noarch -y 出现问题: error: Failed dependencies: libaio.so.1()(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64 解决办法: yum install libaio
如果没有问题,就是安装成功了,继续往下走
2.6 mysql初始化
-- 初始化数据库
mysqld --initialize --console
-- 目录授权,不授权的话MySQL没有写入权限,会启动失败
chown -R mysql:mysql /var/lib/mysql/
-- 启动msyql服务
systemctl start mysqld
-- 停止MySQL命令:
service mysqld stop
-- 查看msyql服务的状态
service mysqld status
成功激活截图:
2.7 本地登录,并修改初始密码
2.7.1 查看临时密码
cat /var/log/mysqld.log
2.7.2 登录mysl
mysql -u root -p
2.7.3 修改密码
alter user 'root'@'localhost' identified by '自己的密码';
2.7.4 刷新权限或退出重登
-- 退出
quit;
-- 刷新权限
flush privileges; # 立即生效
4.1 问题1
参考文献
4.2 问题2
参考文献
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。