0. prerequisite
Since the CentOS system cannot access the internet, it needs to manually download all the necessary MySQL RPM packages and their dependencies to another machine
$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.34-1.el7.x86_64.rpm
$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.34-1.el7.x86_64.rpm
$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.34-1.el7.x86_64.rpm
$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm
Then transfer the RPM packages to CentOS system
1. Install the MySQL RPM packages manually
$ cd ~/Downloads/mysql
$ sudo yum localinstall mysql-community-common-5.7.34-1.el7.x86_64.rpm \
mysql-community-libs-5.7.34-1.el7.x86_64.rpm \
mysql-community-client-5.7.34-1.el7.x86_64.rpm \
mysql-community-server-5.7.34-1.el7.x86_64.rpm \
mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm
Suppose there are some network error messages show up which can be ignored
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#7 - "Failed to connect to 2600:1f16:c1:5e01:4180:6610:5482:c1c0: Network is unreachable"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#7 - "Failed to connect to 2600:1f16:c1:5e01:4180:6610:5482:c1c0: Network is unreachable"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#7 - "Failed to connect to 2600:1f16:c1:5e01:4180:6610:5482:c1c0: Network is unreachable"
2. Start MySQL and set root password
$ sudo systemctl start mysqld
$ sudo systemctl enable mysqld
$ sudo systemctl status mysqld
$ mysql --version
$ sudo grep 'temporary password' /var/log/mysqld.log
2024-06-13T06:35:09.059222Z 1 [Note] A temporary password is generated for root@localhost: +jbqH6Dx;*no
$ sudo mysql_secure_installation
During the mysql_secure_installation
process, you wil be prompted for the root password, enter the temporary password retrieved from the log file, then you can set a new, secure root password
3. Create common user and database
$ mysql -u root -p
> USE mysql;
> SELECT host, user FROM user;
> SET GLOBAL validate_password_policy=LOW;
> SET GLOBAL validate_password_length=4;
> CREATE USER 'manga'@'%' IDENTIFIED BY 'manga';
> ALTER USER 'manga'@'%' IDENTIFIED WITH mysql_native_password BY 'manga';
> SET GLOBAL validate_password_policy=MEDIUM;
> SET GLOBAL validate_password_length=8;
> GRANT ALL PRIVILEGES ON manga.* TO 'manga'@'%';
> GRANT REPLICATION CLIENT ON *.* TO 'manga'@'%';
> GRANT REPLICATION SLAVE ON *.* TO 'manga'@'%';
> FLUSH PRIVILEGES;
> CREATE DATABASE manga;
> ^D
Then you can logon with user "manga" and load SQL scripts as following
$ mysql -hhadoop2 -umanga -pmanga manga
$ source Downloads/mysql/manga.sql;
Note: The MySQL configuration file is typically /etc/my.cnf