我是靠谱客的博主 开放毛豆,最近开发中收集的这篇文章主要介绍centos8 rpm包安装mysql8.0.20数据库数据库应用安装路径:/data安装说明:卸载mysql,postfix,mariadb开始安装MySQL-8.0.20修改数据存储路径及配置文件参数信息,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

数据库应用安装路径:/data

数据库安装包路径:/data/install_mysql
[root@localhost tools]# mkdir -pv /data/install_mysql

将安装包放置指定路径后,解压数据库安装包,并查看;

[root@localhost install_mysql]# tar -xvf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
[root@localhost install_mysql]# ll

在这里插入图片描述

安装说明:

安装MySQL-8.0.20_el7.rpm版本时,如默认已安装mysql,mariadb,postfix等应用,会报错;故,先检查并卸载这些应用;

查看已安装的mysql,mariadb,postfix

说明:如有一下相同相关应用包,可参考 “卸载”方式卸载应用;
[root@localhost ~]# rpm -qa |grep -i mysql
perl-DBD-MySQL-4.023-6.el7.x86_64
qt-mysql-4.8.7-2.el7.x86_64
akonadi-mysql-1.9.2-4.el7.x86_64
[root@localhost ~]# rpm -qa |grep -i mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -qa |grep -i postfix
postfix-2.10.1-7.el7.x86_64

卸载mysql,postfix,mariadb

卸载方式一

说明:卸载方式分两类,相关应用包都一样,可参考以下步骤执行卸载应用;
[root@localhost ~]# rpm -e akonadi-mysql-1.9.2-4.el7.x86_64
[root@localhost ~]# rpm -e mariadb-server-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e perl-DBD-MySQL-4.023-6.el7.x86_64
[root@localhost ~]# rpm -e qt-mysql-4.8.7-2.el7.x86_64
[root@localhost ~]# rpm -e net-snmp-1:5.7.2-37.el7.x86_64
[root@localhost ~]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e postfix-2.10.1-7.el7.x86_64

卸载方式二

依次卸载相关应用软件

[root@localhost ~]# rpm -e perl-DBD-MySQL-4.023-6.el7.x86_64
error: Failed dependencies:
perl-DBD-MySQL is needed by (installed) mariadb-server-1:5.5.60-1.el7_5.x86_64

解决卸载应用依赖包

[root@localhost ~]# rpm -e mariadb-server-5.5.60-1.el7_5.x86_64
error: Failed dependencies:
mariadb-server is needed by (installed) akonadi-mysql-1.9.2-4.el7.x86_64

解决卸载应用依赖包

[root@localhost ~]# rpm -e akonadi-mysql-1.9.2-4.el7.x86_64
[root@localhost ~]# rpm -e mariadb-server-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e perl-DBD-MySQL-4.023-6.el7.x86_64
[root@localhost ~]# rpm -e qt-mysql-4.8.7-2.el7.x86_64
[root@localhost ~]# rpm -e postfix-2.10.1-7.el7.x86_64

解决卸载应用依赖包

[root@localhost ~]# rpm -qa |grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed) net-snmp-1:5.7.2-37.el7.x86_64
mysql-libs is needed by (installed) net-snmp-1:5.7.2-37.el7.x86_64
[root@localhost ~]# rpm -e net-snmp-1:5.7.2-37.el7.x86_64
[root@localhost ~]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64

开始安装MySQL-8.0.20

前往安装包路径:

[root@localhost data]# cd install_mysql/

依次执行安装命令:

rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm

查看安装组件

[root@localhost install_mysql]# rpm -qa |grep mysql
mysql-community-libs-compat-8.0.20-1.el7.x86_64
mysql-community-server-8.0.20-1.el7.x86_64
mysql-community-libs-8.0.20-1.el7.x86_64
mysql-community-common-8.0.20-1.el7.x86_64
mysql-community-client-8.0.20-1.el7.x86_64

启动mysql

[root@localhost install_mysql]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service

更改密码

[root@localhost data]# cat /var/log/mysqld.log|grep password
2021-08-08T05:54:40.369790Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: -AopAbk<e1t3

登录数据库

[root@localhost data]# mysql -uroot -p
Enter password: -AopAbk<e1t3
mysql> ALTER USER ‘root’@‘localhost’ identified by ‘Abcd_1234567#’ password expire never;
mysql> INSTALL PLUGIN CONNECTION_CONTROL SONAME ‘connection_control.so’;
mysql> INSTALL PLUGIN CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS SONAME ‘connection_control.so’;
mysql> commit;
mysql> exit

添加不区分大小写参数

编辑MySQL服务配置文件,添加下列信息;

lower_case_table_names=1

说明:MySQL-8版本默认不支持“大小写区分”,配置文件中添加此参数后,需初始化mysql数据;

停止mysql服务并删除初始化数据

停止数据库服务

[root@localhost data]# service mysqld stop

删除已生成mysql初始化参数

[root@localhost data]# rm -rf /var/lib/mysql/*

启动mysql服务

[root@localhost data]# service mysqld start

修改数据存储路径及配置文件参数信息

编辑mysql配置文件

[root@localhost data]# vi /etc/my.cnf

将以下参数添加至/etc/my.cnf配置文件中;

[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
skip-slave-start
validate_password.length=12
validate_password.policy=2
connection_control_failed_connections_threshold=5
connection_control_min_connection_delay=60000
max_connections=16384
wait_timeout=14400
interactive_timeout=14400
skip-name-resolve
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
server_id=101
port=33306
log_bin_trust_function_creators = 1
lower_case_table_names=1
#[mysqldump]
#user = ntjtcloud
#password = Abcd_1234567#

创建数据存储目录并赋权:

[root@localhost data]# mkdir mysql
[root@localhost data]# chown mysql:mysql /data/mysql
[root@localhost data]# cp -a -r /var/lib/mysql/
/data/mysql
[root@localhost data]# cp /etc/my.cnf /etc/my.cnf.bk
*

停止并启动数据库服务

[root@localhost data]# service mysqld stop
[root@localhost data]# service mysqld start

创建用户和数据库

创建普通用户并设置密码
用户:cloud
密码:Abcd_1234567#
新建用户和密码,并设置密码永不过期
create user ‘cloud’@’%’ identified by ‘Abcd_1234567#’;
ALTER USER ‘cloud’@’%’ IDENTIFIED WITH mysql_native_password BY ‘Abcd_1234567#’;
创建数据库:test1
create database test1;
授权用户对数据库有所有权限
grant all privileges on test1.* to ‘ntjtcloud’@’%’;
创建数据库:test2
create database test2;
授权用户对数据库有所有权限
grant all privileges on test2.* to ‘ntjtcloud’@’%’;
刷新权限
flush privileges;

最后

以上就是开放毛豆为你收集整理的centos8 rpm包安装mysql8.0.20数据库数据库应用安装路径:/data安装说明:卸载mysql,postfix,mariadb开始安装MySQL-8.0.20修改数据存储路径及配置文件参数信息的全部内容,希望文章能够帮你解决centos8 rpm包安装mysql8.0.20数据库数据库应用安装路径:/data安装说明:卸载mysql,postfix,mariadb开始安装MySQL-8.0.20修改数据存储路径及配置文件参数信息所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(75)

评论列表共有 0 条评论

立即
投稿
返回
顶部