CentOS offline install mysql8.0

Use rpm package to offline install mysql8.0
version as mysql-8.0.19

environmental test

Check if the rpm package of mariadb exists in the system

rpm -qa|grep mariadb

Insert picture description here
Uninstall if it exists

rpm -e mariadb-libs-5.5.64-1.el7.x86_64

Download and unzip mysql8-0

  • Download using wget command
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar
  • Download in browser

Browser enter the URL https://downloads.mysql.com/archives/community/
select the operating system version, click download
Insert picture description here

  • Detect md5 value

After the installation package is downloaded, check the md5 value of the installation package

md5sum mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar

Insert picture description here
Insert picture description here

  • Unzip the tar package
tar -xvf mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar

The decompressed package is shown in the figure
Insert picture description here

  • Install mysql
rpm -ivh mysql-community-common-8.0.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.19-1.el7.x86_64.rpm

Note: Installation needs to be installed in the order of common, libs, clien, server

  • Check if the installation is successful
rpm -qa|grep mysql

As shown in the figure below, the installation is successful
Insert picture description here

  • Modify the configuration file
#备份旧的配置文件
mv /etc/my.cnf /etc/my.cnf.bak
#编辑配置文件
vim /etc/my.cnf

Change the database port, path and other parameters.

  • Create mysql installation path and modify permissions
mkdir /home/mysql8.0
chown -R mysql:mysql /home/mysql8.0
  • mysql initialization
#指定安装路径初始化,路径需和配置文件中一致
/sbin/mysqld --user=mysql  --initialize --basedir=/home/mysql8.0 --datadir=/home/mysql8.0/data

Note: MySQL is case-sensitive by default. If you need to change it to case-insensitive, set lower-case-table-names=1 in the configuration file and initialization, and set it in one place, that is, the configuration file and initialization are inconsistent , Will start
as/sbin/mysqld --user=mysql --initialize --basedir=/home/mysql8.0 --datadir=/home/mysql8.0/data --lower-case-table-names=1
Insert picture description here

  • Start mysql and set to start automatically
systemctl start mysqld
systemctl enable mysqld
  • Get mysql initial password
#/home/mysql8.0/data/mysqld.log为mysql错误日志
`cat "/home/mysql8.0/data/mysqld.log" | grep password | head -1 | rev  | cut -d ' ' -f 1 | rev`
  • Login to mysql using the initial screen
mysql -uroot -p
  • Change root password
alter user 'root'@'localhost' identified  by '$123456';
create user 'root'@'%' identified  by '$123456';
grant all privileges on *.* to 'root'@'%' with grant option;
create user 'root'@'127.0.0.1' identified  by '$123456';
grant all privileges on *.* to 'root'@'127.0.0.1' with grant option;
flush privileges;
  • Use the new password to log in to mysql
mysql -uroot -p123456

Insert picture description here

Guess you like

Origin blog.csdn.net/xiguashixiaoyu/article/details/108777534