CENTOS version: 7.5
Database version: 8
The server switches frequently, and the official website of the database is slow to download. It can wait until the end of time, so it is still downloaded from domestic sources. Tsinghua source is recommended here. The download speed is not bad. Download the tar package and upload it to the server.
1. Download the rpm package
Add a link description
and select the version you downloaded.
I downloaded the 8.0 version here and clicked it in MYSQL 8.0/
. Then the keyboard ctrl + f
will appear in the search box and input. mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar
Find and download it locally and
unzip it to get it.
# 这里我们只需要 一下几个 rpm 文件
mysql-community-common-8.0.19-1.el7.x86_64.rpm
mysql-community-libs-8.0.19-1.el7.x86_64.rpm
mysql-community-client-8.0.19-1.el7.x86_64.rpm
mysql-community-server-8.0.19-1.el7.x86_64.rpm
# 这几个 rpm 上传到服务器上 /usr/local/mysql/ 下
2. Environment preparation work, there will be problems later if mariadb is not uninstalled
1. Check whether to download mariadb
rpm -qa|grep mariadb
2. If it exists, delete it or uninstall it with yum
rpm -e mariadb-libs-5........(查出来的名字 直接复制就可以)
If the above method cannot be uninstalled, you can executeyum -y remove mariadb-libs-5.5.44-2.el7.centos.x8664
–
Then execute the commands one by one to deal with environmental problems to avoid errors later
yum install openssl-devel.x86_64 openssl.x86_64 -y
yum install perl.x86_64 perl-devel.x86_64 -y
yum install perl-JSON.noarch -y
yum -y install autoconf
3. Install mysql
Do not mess up the order
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-client-8.0.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.19-1.el7.x86_64.rpm
If rpm -ivh mysql-community-libs-8.0.19-1.el7.x86_64.rpm executes incorrectly,
delete mariadb according to the environment preparation stage
At this point, mysql is already installed, and the following describes how to use it
4. The use of mysql
*********************** Execute the following commands in turn to see
Initialize the database: mysqld --initialize --console
check the service status : systemctl status mysqld
-mysql service status is closed
stop mysql service: service mysqld stop
directory authorization chown -R mysql:mysql /var/lib/mysql/
mysql service start: systemctl start mysqld
check the status again after startup systemctl status mysqld
orps aux | grep mysql
5. Database operation
View the initial password: cat /var/log/mysqld.log
The initial password just installed here is =A4fl&NMy?K;
Then enter the command mysql -u root -p
to enter the database
, then enter the initial password and press Enter to enter the database
Configure in sequence according to the following commands:
1.修改密码
alter USER 'root'@'localhost' IDENTIFIED BY '123456';
flush privileges;
2.授权远程连接
show databases;
use mysql;
select host, user, authentication_string, plugin from user;
update user set host = "%" where user='root';
select host, user, authentication_string, plugin from user;
flush privileges;
3. 再服务器 安全组 和端口开启 3306 并且用远程试着链接