centos7離線安裝mysql
1、安裝新版mysql前,需將系統自帶的mariadb-lib卸載
rpm -qa|grep mariadb
[root@host]# 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