Linux offline installation of mysql: 5.7.36 (super detailed tutorial)

Linux offline installation mysql:5.7.36 environment preparation

Official website download address: click to jump to download

  1. Select the installation package version according to the server system version
  2. If the server can be connected to the Internet, you can use wget to download
 wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz

Path allocation, decompression installation:

  1. Path assignment (没有路径要求,这步可省略):
cd /data

mkdir mysql

cd mysql
  1. Download the installation package
 wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
  1. Unzip the installation package
tar tar -zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
  1. file rename(方便后续操作,建议重命名)
mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql5.7
  1. Create mysql group and mysql user to change permissions:
groupadd mysql

useradd -r -g mysql mysql 

chown -R mysql:mysql mysql5.7

chmod -R 775 mysql5.7
  1. Create data directory
cd mysql5.7

mkdir data
  1. initialize mysql
cd /data/mysql/mysql5.7/bin

./mysqld --initialize --user=mysql --datadir=/data/mysql/mysql5.7/data --basedir=/data/mysql/mysql5.7
  1. After the initialization is complete, a temporary password will appear at the end. My temporary password here is: >w0;,sxSCbRLrecord this temporary password, which will be used later
    insert image description here
  2. Create files in the /data/mysql directory
vim support-files/mysql.server 
  1. Create link:
ln -s /data/mysql/mysql5.7/support-files/mysql.server /etc/init.d/mysql
cd /data/mysql/mysql5.7/bin

ln -s /data/mysql/mysql5.7/bin/mysql /usr/local/bin/mysql
  1. Edit the my.cnf file vim /etc/my.cnf, the content is as follows (可根据实际情况添加配置):
[mysql]
default-character-set=utf8
[mysqld]
skip-name-resolve
port = 3306
bind-address=0.0.0.0
basedir=/data/mysql/mysql5.7
datadir=/data/mysql/mysql5.7/data
character-set-server=utf8
  1. start mysql
    启动时可能会报关于pid的错,检查进程是否占用端口,kill该进程,然后重新启动
service mysql start

If it is not a port problem, does it prompt /etc/init.d/mysqld file problem, check the configuration file
找到这两行,改成mysql5.7的安装路径

insert image description here

  1. Set the boot to start automatically:
chkconfig --add mysql
  1. Check whether the self-starting is successful
chkconfig --list
  1. Log in to mysql in the bin directory of mysql5.7回车之后输入临时密码
mysql -uroot -p
  1. To change the password in the database:
set password for root@localhost = password('*******');
  1. Add remote user password:
grant all privileges on *.* to 'root'@'%' identified by '******';

FLUSH PRIVILEGES;

Guess you like

Origin blog.csdn.net/qq_62242833/article/details/128341997
Recommended