A, download
- Download address: dev.mysql.com/downloads/m…
The current download version is mysql-8.0.27-1.el7.x86_64, this installation uses mysql-8.0.23-1.el7.x86_64.
-
Install mysql-8.0.23-1.el7.x86_64
Reply to mysql on wechat public account [Java and Big Data Advanced].
Second, the unloading
2.1 Viewing the Mariadb Installation Package
[root@hadoopserver ~]# rpm -qa | grep mariadbMariadb - libs - 5.5.44-2. El7. Centos. X86_64Copy the code
Uninstall mariadb 2.2
[root@hadoopserver ~]RPM -e mariadb-libs-5.5.44-2.el7.centos.x86_64 --nodeps
Copy the code
2.3 Check whether Mariadb is uninstalled successfully
Install MySQL 8.0
3.1 Creating a MySQL User
[root@hadoopserver local]# groupadd mysql
[root@hadoopserver local]# useradd -g mysql mysql
[root@hadoopserver local]# passwd mysql
Copy the code
3.2 Uploading the MySQL RPM package
[root@hadoopserver local]# rz
Copy the code
3.3 Creating a Folder in the MySQL installation Location
[root@hadoopserver local]# mkdir mysql
# Set permission group
[root@hadoopserver local]# chown mysql:mysql ./mysql
Copy the code
3.4 Decompressing the mysql RPM Package
Unzip the file into the mysql folder you just created
[root@hadoopserver local]# tar -xf mysql-8.0.23-1.el7.x86_64. RPM -bundle.tar -c
Copy the code
3.5 license
Enter the MySQL installation directory
[root@hadoopserver local]# cd mysql
Grant all permissions (read, write, execute)
[root@hadoopserver mysql]# chmod -R 777 *
Copy the code
Install MySQL 3.6
Install the following RPM packages in sequence:
Mysql - community - common - 8.0.23-1. El7. X86_64. RPM mysql - community - libs - 8.0.23-1. El7. X86_64. RPM Mysql - community - the client - 8.0.23-1. El7. X86_64. RPM mysql - community - server - 8.0.23-1. El7. X86_64. RPMCopy the code
Run the following command
[root@hadoopserver mysql]# RPM -ivh mysql-community-common-8.0.23-1.el7.x86_64. RPM --nodeps --force [root@hadoopserver Mysql]# RPM -ivh mysql-community-libs-8.0.23-1.el7.x86_64. RPM --nodeps --force [root@hadoopserver mysql]# RPM -ivh Mysql -community-client-8.0.23-1.el7.x86_64. RPM --nodeps --force [root@hadoopserver mysql]# RPM -ivh Mysql - community - server - 8.0.23-1. El7. X86_64. RPM -- nodeps - forceCopy the code
The –nodeps –force command is used to force the installation regardless of the missing dependencies
3.7 Checking whether the installation is successful
[root@hadoopserver mysql]# rpm -qa|grep mysqlMysql - community - libs - 8.0.23-1. El7. X86_64 mysql - community - common - 8.0.23-1. El7. X86_64 Mysql - community - the client - 8.0.23-1. El7. X86_64 mysql - community - server - 8.0.23-1. El7. X86_64Copy the code
MySQL > configure MySQL
4.1 Initializing the mysql Database
[root@hadoopserver mysql]# mysqld --initialize --user=mysql
Copy the code
4.2 Viewing and Initializing random Passwords
[root@hadoopserver mysql]# cat /var/log/mysqld.log
2021-11-16T09:54:29.033732Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: bbZQqlUH2r&1
Copy the code
The initial password is bbzqqluH2r&1
4.3 Starting the MySQL Database
Start the mysql database service
[root@hadoopserver mysql]# systemctl start mysqld.service
Check the mysql service status
[root@hadoopserver mysql]# systemctl status mysqld.service
Allow services to start upon startup
[root@hadoopserver mysql]# systemctl enable mysqld.service
Copy the code
4.4 Log in to the MySQL database and reset the root password
# login MySQL
[root@hadoopserver mysql]# mysql -u root -p
Reset password
mysql> alter user 'root'@'localhost' identified by '123456';
# check the mysql version
mysql>select version();
Copy the code
4.5 Using the New Password for Login
[root@hadoopserver mysql]# mysql -u root -p123456
Copy the code
5. Connect to MySQL
5.1 Check whether the firewall is disabled
Check the firewall status
firewall-cmd --state
# stop the firewall
systemctl stop firewalld.service
Disable firewall startup
systemctl disable firewalld.service
Copy the code
5.2 Or Enable Port 3306
Open the specified port
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# Disable the specified port
firewall-cmd --zone=public --remove-port=3306/tcp --permanent
# restart firewall
firewall-cmd --reloadl
Copy the code
5.3 Changing host in mysql tablespace user
mysql> use mysql;
mysql> update user set host=The '%' where user='root';
This command must be executed twice
mysql> Grant all privileges on root.* to 'root'@The '%';
Copy the code
5.4 Using Navicat for Connection
Test connection successful!