Linux offline installation mysql:5.7.36 environment preparation
Official website download address: click to jump to download
- Select the installation package version according to the server system version
- 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:
- Path assignment
(没有路径要求,这步可省略)
:
cd /data
mkdir mysql
cd mysql
- 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
- Unzip the installation package
tar tar -zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
- file rename
(方便后续操作,建议重命名)
mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql5.7
- 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
- Create data directory
cd mysql5.7
mkdir data
- initialize mysql
cd /data/mysql/mysql5.7/bin
./mysqld --initialize --user=mysql --datadir=/data/mysql/mysql5.7/data --basedir=/data/mysql/mysql5.7
- After the initialization is complete, a temporary password will appear at the end. My temporary password here is:
>w0;,sxSCbRL
record this temporary password, which will be used later
- Create files in the /data/mysql directory
vim support-files/mysql.server
- 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
- 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
- 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的安装路径
- Set the boot to start automatically:
chkconfig --add mysql
- Check whether the self-starting is successful
chkconfig --list
- Log in to mysql in the bin directory of mysql5.7
回车之后输入临时密码
mysql -uroot -p
- To change the password in the database:
set password for root@localhost = password('*******');
- Add remote user password:
grant all privileges on *.* to 'root'@'%' identified by '******';
FLUSH PRIVILEGES;