安装MySQL5.7到CentOS7(无网络)

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

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值