centos7离线安装mysql

Posted nhs3217

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7离线安装mysql相关的知识,希望对你有一定的参考价值。

1、安装新版mysql前,需将系统自带的mariadb-lib卸载

rpm -qa|grep mariadb
[[email protected]]# mariadb-libs-5.5.44-2.el7.centos.x86_64
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64

2、下载mysql离线包

下载地址:https://dev.mysql.com/downloads/mysql/#downloads

解压:tar xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar

3、创建mysql的yum源

createrepo mysql目录

添加yum源文件

4、安装mysql

yum install mysql-server

5、获取mysql密码

密码在/var/log/mysqld.log里,获取:grep "password" /var/log/mysqld.log

用该密码登录到服务端后,必须马上修改密码,不然会报如下错误:
mysql> select user();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.


如果只是修改为一个简单的密码,会报以下错误:
mysql> ALTER USER USER() IDENTIFIED BY ‘12345678‘; 
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
这个其实与validate_password_policy的值有关。

参考:https://www.cnblogs.com/ivictor/p/5142809.html

6、修改密码

set global validate_password_policy=0;
set global validate_password_length=1;

ALTER USER USER() IDENTIFIED BY ‘12345678‘;

或:set password=password(‘mysql‘);

7、设置mysql开机启动
// 检查是否已经是开机启动
systemctl list-unit-files | grep mysqld
// 开机启动
systemctl enable mysqld.service

8、创建用户,分配权限,远程登陆授权
mysql -uroot -pmysql
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘mysql‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
初始化hive库
mysql -u root -pmysql
CREATE USER ‘hive‘@‘%‘ IDENTIFIED BY ‘hive‘;
GRANT ALL PRIVILEGES ON *.* TO ‘hive‘@‘%‘;
CREATE USER ‘hive‘@‘localhost‘ IDENTIFIED BY ‘hive‘;
GRANT ALL PRIVILEGES ON *.* TO ‘hive‘@‘localhost‘;
CREATE USER ‘hive‘@‘hostname‘ IDENTIFIED BY ‘hive‘;
GRANT ALL PRIVILEGES ON *.* TO ‘hive‘@‘hostname‘;
FLUSH PRIVILEGES;
CREATE DATABASE `hive` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

 



























以上是关于centos7离线安装mysql的主要内容,如果未能解决你的问题,请参考以下文章

centos7离线安装mysql

centos7离线安装mysql

CentOS7离线安装Mysql8.0

Centos7离线安装MySQL

Centos7离线安装MySQL

CentOS7 离线安装MySQL