Installing MySQL database when the server is not connected to the Internet

Time:2021-4-14

brief introduction

In some cases, the server can’t connect to the network. At this time, you can’t install MySQL database through yum. Fortunately, many domestic image stations provide the package download function. You can download the package to the local and install it through the U disk or CD-ROM drive. In a few days, I encountered this situation, first record the whole installation process as follows.

Specific operation

Installation dependency

To install MySQL in a non network environment, you need to install the required dependency package first. After the download is successful, enter the folder to executerpm -ivh *.rpm --nodeps --forceThat’s it.

Download installation package

It’s too slow to download the installation package from the official website. It’s recommended to use domestic image sources, such as:Huawei open source image stationTsinghua University open source software mirror stationAnd so on. Take Huawei source as an example:

  • Choose MySQL

Installing MySQL database when the server is not connected to the Internet

  • Download and select the appropriate version

Installing MySQL database when the server is not connected to the Internet

Installing MySQL database when the server is not connected to the Internet

  • Select the corresponding operating system installation package (here for centos7)

Installing MySQL database when the server is not connected to the Internet

install

Ensure that the dependent package is installed

  1. Extract the file to the specified directory
#Unzip to / usr / local/
tar -zxvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
  1. Rename a file (optional)
mv mysql-5.7.31-linux-glibc2.12-x86_64 mysql

Installing MySQL database when the server is not connected to the Internet

  1. Edit profile

By default, in/etc/It exists in the directorymy.cnfThis file is the configuration file of MySQL, which can be used as a reference

[mysqld]
#Port
port=3306
#Data saving path
datadir=/usr/local/mysql/data
#Socket file
socket=/usr/local/mysql/mysql.sock
#Start user
user=root
#Maximum connections
max_connections=151
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#Set ignore case
lower_case_table_names = 1

#Specify the encoding
character-set-server=utf8

collation-server=utf8_general_ci

#Open IP binding
bind-address = 0.0.0.0

[mysqld_safe]
#Log path
log-error=/var/log/mysqld.log
#Save path of process ID after startup
pid-file=/var/run/mysqld/mysqld.pid

#Client related
[client]
socket=/usr/local/mysql/mysql.sock
default-character-set=utf8

#Solution to the problem of using group by after database upgrade 5.7 https://blog.csdn.net/study_ in/article/details/92625397
[mysqld]
sql_mode =STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  1. Enter the MySQL installation directory to install
#Enter directory
cd /usr/local/mysql/
#Specify the startup user, data saving path, etc
./bin/mysqld --user=root --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
#After starting MySQL and performing this step, the random password of login database will appear. Please save it
./support-files/mysql.server start
#Putting MySQL into system service
cp $m/support-files/mysql.server /etc/init.d/mysqld
#Perform database restart
service mysqld restart
  1. Environment variable configuration
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
#Reload
source /etc/profile
  1. Check MySQL status
service mysqld status

At this point, the MySQL database has been successfully installed. Next, you need to log in to the database and reset the password. After the reset is successful, exit and log in with the new password

#Login database
mysql -u -root -p
#Set a new password
Set password = password ('New password ');

Install with script

Follow the above steps to install successfully, but it’s too troublesome. Then I wrote a script, and the steps are as follows

  1. Download the file and upload it to the server
  2. Unzip and enter the folder
  3. implementsh install_rpm.shInstallation dependency
  4. implementsh install_mysql.shInstall MySQL
  5. Verify the results

summary

Script installation is recommended, which is simple and fast. (there is something wrong with the script, please comment)

  • Start MySQL:service mysqld start
  • Stop MySQL:service mysqld stop
  • Query status:service mysqld status

Download address

Original link

Recommended Today

Installation and configuration of node.js and NPM

Installation of node.js CentOS installation: $ dnf module list nodejs $ dnf module install nodejs:14 Windows installation: https://nodejs.org/en/download/ To view the installed version: $ node -v NPM installation Node.js has a built-in NPM package management tool, which does not need to be installed separately. To view the installed version: $ npm -v Upgrade NPM to […]