1.准备工作
1.1将安装包和JDBC驱动上传到远程服务器上,共计如下
01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-connector-java-5.1.27-bin.jar
1.2.将虚拟机中有过mysql以及mariadb全部卸载。
[maxwell@hadoop102 ~]$ rpm -qa | grep -i -E mysql\|mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[maxwell@hadoop102 ~]$ rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps
[maxwell@hadoop102 ~]$
1.3 卸载、安装相关依赖包
[maxwell@hadoop102 ~]$ sudo yum remove mysql-libs
Loaded plugins: fastestmirror, langpacks
No Match for argument: mysql-libs
No Packages marked for removal
[maxwell@hadoop102 ~]$ sudo yum install libaio
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Package libaio-0.3.109-13.el7.x86_64 already installed and latest version
Nothing to do
[maxwell@hadoop102 ~]$ sudo yum -y install autoconf
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed
--> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(Data::Dumper) for package: autoconf-2.69-11.el7.noarch
--> Running transaction check
---> Package m4.x86_64 0:1.4.16-10.el7 will be installed
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================================================================================================================
Installing:
autoconf noarch 2.69-11.el7 base 701 k
Installing for dependencies:
m4 x86_64 1.4.16-10.el7 base 256 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
Transaction Summary
=========================================================================================================================================================================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 1.0 M
Installed size: 2.8 M
Downloading packages:
(1/3): m4-1.4.16-10.el7.x86_64.rpm | 256 kB 00:00:00
(2/3): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(3/3): autoconf-2.69-11.el7.noarch.rpm | 701 kB 00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.1 MB/s | 1.0 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 11 pre-existing rpmdb problem(s), 'yum check' output follows:
icedtea-web-1.7.1-1.el7.x86_64 has missing requires of java-1.8.0-openjdk
icedtea-web-1.7.1-1.el7.x86_64 has missing requires of jpackage-utils
icedtea-web-1.7.1-1.el7.x86_64 has missing requires of jpackage-utils
jline-1.0-8.el7.noarch has missing requires of java >= ('0', '1.5', None)
jline-1.0-8.el7.noarch has missing requires of jpackage-utils
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
rhino-1.7R5-1.el7.noarch has missing requires of jpackage-utils
rhino-1.7R5-1.el7.noarch has missing requires of jpackage-utils
tagsoup-1.2.1-8.el7.noarch has missing requires of jpackage-utils
tagsoup-1.2.1-8.el7.noarch has missing requires of jpackage-utils >= ('0', '1.6', None)
Installing : m4-1.4.16-10.el7.x86_64 1/3
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 2/3
Installing : autoconf-2.69-11.el7.noarch 3/3
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 1/3
Verifying : m4-1.4.16-10.el7.x86_64 2/3
Verifying : autoconf-2.69-11.el7.noarch 3/3
Installed:
autoconf.noarch 0:2.69-11.el7
Dependency Installed:
m4.x86_64 0:1.4.16-10.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7
Complete!
[maxwell@hadoop102 ~]$
2.正式安装
2.1 安装依赖
[maxwell@hadoop102 module]$ cd /opt/software/
[maxwell@hadoop102 software]$ ls -ltr
total 865892
-rwxrwxr-x. 1 root root 195013152 Oct 7 17:30 jdk-8u212-linux-x64.tar.gz
-rwxrwxr-x. 1 root root 338075860 Oct 7 17:30 hadoop-3.1.3.tar.gz
-rw-rw-r--. 1 maxwell maxwell 9311744 Mar 23 14:28 apache-zookeeper-3.5.7-bin.tar.gz
-rw-rw-r--. 1 maxwell maxwell 86486610 Mar 23 15:08 kafka_2.12-3.0.0.tgz
-rw-rw-r--. 1 maxwell maxwell 67938106 Mar 23 15:34 apache-flume-1.9.0-bin.tar.gz
-rw-rw-r--. 1 maxwell maxwell 277604 Mar 25 15:50 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
-rw-rw-r--. 1 maxwell maxwell 2112700 Mar 25 15:50 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
-rw-rw-r--. 1 maxwell maxwell 2237116 Mar 25 15:50 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
-rw-rw-r--. 1 maxwell maxwell 25034716 Mar 25 15:50 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
-rw-rw-r--. 1 maxwell maxwell 872303 Mar 25 15:50 mysql-connector-java-5.1.27-bin.jar
-rw-rw-r--. 1 maxwell maxwell 159295840 Mar 25 15:50 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
[maxwell@hadoop102 software]$ sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
warning: 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.16-1.e################################# [100%]
[maxwell@hadoop102 software]$ sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
warning: 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.16-1.el7################################# [100%]
[maxwell@hadoop102 software]$ sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
warning: 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-compat-5.7.1################################# [100%]
[maxwell@hadoop102 software]$
2.2 安装mysql-client
[maxwell@hadoop102 software]$
[maxwell@hadoop102 software]$ sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
warning: 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.16-1.e################################# [100%]
[maxwell@hadoop102 software]$
2.3 安装mysql-server
[maxwell@hadoop102 software]$
[maxwell@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
warning: 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.16-1.e################################# [100%]
[maxwell@hadoop102 software]$
2.4 启动MySQL
[maxwell@hadoop102 software]$
[maxwell@hadoop102 software]$ sudo systemctl start mysqld
[maxwell@hadoop102 software]$
2.5 查看MySQL密码
[maxwell@hadoop102 software]$
[maxwell@hadoop102 software]$ sudo cat /var/log/mysqld.log | grep password
2023-03-25T08:10:27.603660Z 1 [Note] A temporary password is generated for root@localhost: oWANR9!w=pJL
[maxwell@hadoop102 software]$
3.配置MySQL
配置只要是root用户 + 密码,在任何主机上都能登录MySQL数据库。
3.1 用2.5查询到的密码进入MySQL
[maxwell@hadoop102 software]$ mysql -uroot -p'oWANR9!w=pJL'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3.2 设置复杂密码(由于MySQL密码策略,此密码必须足够复杂)
mysql>
mysql> set password=password("centos=so");
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
3.3 更改MySQL密码策略
mysql>
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql>
3.4 重新设置密码
mysql> set password=password("centos123");
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
3.5 进入MySQL库
mysql>
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>
3.6 查询user表
mysql>
mysql> select user,host from user;
+-----------+-----------+
| user | host |
+-----------+-----------+
| mysql.sys | localhost |
| root | localhost |
+-----------+-----------+
2 rows in set (0.00 sec)
mysql>
3.7 修改user表,把Host表内容修改为%
mysql>
mysql> update user set host="%" where user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host from user;
+-----------+-----------+
| user | host |
+-----------+-----------+
| root | % |
| mysql.sys | localhost |
+-----------+-----------+
2 rows in set (0.00 sec)
mysql>
3.8 刷新一下
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
3.9 退出
mysql>
mysql> quit;
Bye
[maxwell@hadoop102 software]$
4. 业务数据模拟
4.1 通过可视化客户端连接MySQL