1. First go to the MYSQL official website to download mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar, there are several versions, some are for cluster use, some are for single machine. I downloaded the standalone
Because the operation searched for many posts, the operation was a bit messy. Do it in order and it should work.
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
This is what I unzipped. . .
mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-8.0.11-1.el7.x86_64.rpm
mysql-community-common-8.0.11-1.el7.x86_64.rpm
mysql-community-devel-8.0.11-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.11-1.el7.x86_64.rpm
mysql-community-libs-8.0.11-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.11-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-8.0.11-1.el7.x86_64.rpm
mysql-community-server-8.0.11-1.el7.x86_64.rpm
mysql-community-server-minimal-8.0.11-1.el7.x86_64.rpm
mysql-community-test-8.0.11-1.el7.x86_64.rpm
Check the installed MYSQL and uninstall
rpm -qa | grep mysql
Use the command rpm -e --nodeps {-file-name}
to remove, there may be dependencies when removing, pay attention to a certain order.
There is only one MYSQL or something in my system. I uninstalled only one and restarted it.
Third, use the rpm command to install the MySql component
Install using the command rpm -ivh {-file-name}
.
1 [root@sxl129 Downloads]# rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm
2 warning: mysql-community-common-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
3 Preparing... ########################################### [100%]
4 1:mysql-community-common ########################################### [100%]
5 [root@sxl129 Downloads]# rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm
6 warning: mysql-community-libs-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
7 Preparing... ########################################### [100%]
8 1:mysql-community-libs ########################################### [100%]
9 [root@sxl129 Downloads]# rpm -ivh mysql-community-libs-compat-5.7.20-1.el6.x86_64.rpm
10 warning: mysql-community-libs-compat-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
11 Preparing... ########################################### [100%]
12 1:mysql-community-libs-co########################################### [100%]
13 [root@sxl129 Downloads]# rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm
14 warning: mysql-community-client-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
15 Preparing... ########################################### [100%]
16 1:mysql-community-client ########################################### [100%]
17 [root@sxl129 Downloads]# rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm
18 warning: mysql-community-server-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
19 Preparing... ########################################### [100%]
20 1:mysql-community-server ########################################### [100%]
Note: In ivh, installation; progress bar; hash check i-install
v-verbose
h-hash
The above is to copy the installation sequence of others and that's it.
4. Log in and create a MySql password
1. Start Mysql
安装完后,使用命令service mysqld start
启动MySQL服务。
2、修改MySql的密码
由于MySQL5.7.4之前的版本中默认是没有密码的,登录后直接回车就可以进入数据库,进而进行设置密码等操作。其后版本对密码等安全相关操作进行了一些改变,在安装过程中,会在安装日志中生成一个随机密码。
怎么找到这个随机密码呢?
使用:
1 grep 'temporary password' /var/log/mysqld.log
即可查询到类似于如下的一条日志记录:
1 [root@sxl129 Downloads]# grep 'temporary password' /var/log/mysqld.log
2 2017-12-03T10:34:49.423162Z 1 [Note] A temporary password is generated for root@localhost: hqQRMP:D)9Q&
hqQRMP:D)9Q&即为登录密码。使用这个随机密码登录进去,然后修改密码,使用命令:
mysql -uroot -p
The above is to copy someone else's, and there is no problem in starting the service. There is no problem finding the password, and then the login prompts an error.
[root@localhost www]# mysql -uroot -pvgJp_8Wft+7
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Then go to Baidu to find the answer.
It's useless to find the answer for a long time, because I copied the wrong password and lost one / the password is / vgJp_8Wft+7
Too pit. . . Then log in
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Chai123!'
Change the password, it can't be too simple or too simple and an error is reported. Anyway, 8 and 5.7 have strengthened password verification.
I tried to find parameters to simplify the password strength, but it didn't work. .
Let's do this first. Explore later!