检查节点中是否自带mysql:
rpm -qa | grep mysql
rpm -qa | grep mariadb
如果有安装,需要卸载系统自带:
rpm -e mysql【一般删除,如果提示以来的其他文件,则不能删除】
rpm -e --nodeps mysql【强制删除,包含各种依赖包】
yum -y remove mysql* 【删除软件的时候会删除对该软件具有依赖关系的包】
【Tips:三种方式任选】
下载 mysql57-community-release-el7-9.noarch.rpm 的yum源:
wget http://mirrors.ustc.edu.cn/mysql-repo/mysql57-community-release-el7-9.noarch.rpm
安装rpm文件:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum安装mysql-community-server
yum -y install mysql-community-server
关闭强密码验证:
vim /etc/my.cnf
# 增加如下内容
plugin-load=validate_password.so
validate-password=OFF
启动mysql服务:
service mysqld start
获取随机密码:
[root@master ~]# grep "password" /var/log/mysqld.log
[Note] A temporary password is generated for root@localhost: r+RWXg*a7e%1
更改密码,进入mysql;
mysql -u root -p
mysql> SET PASSWORD = PASSWORD(‘123456‘);
mysql> ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
mysql> flush privileges;
查询用户表:
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select User,authentication_string,Host from user;
+---------------+-------------------------------------------+-----------+
| User | authentication_string | Host |
+---------------+-------------------------------------------+-----------+
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
+---------------+-------------------------------------------+-----------+
3 rows in set (0.00 sec)
设置任意IP访问:
mysql> grant all privileges on *.* to root@"%" identified by "123456";
mysql> flush privileges;
退出mysql:exit 设置开机启动mysql服务:systemctl enable mysqld
7.安装mysql连接工具
wget https://cdn.mysql.com/archives/mysql-connector-java-5.1/mysql-connector-java-5.1.45.tar.gz
tar -zxvf mysql-connector-java-5.1.45.tar.gz
cd mysql-connector-java-5.1.45
cp mysql-connector-java-5.1.45-bin.jar $HIVE_HOME/lib/