[root@server2 ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [root@server2 ~]# uname -r 3.10.0-693.el7.x86_64
rpm -qa | grep mysql rpm -qa | grep mariadb
rpm -e --nodeps {file_name} # {file_name} 是查询到的程序名
网址:https://downloads.mysql.com/archives/community/
yum install -y wget
下载地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
[root@server2 ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
[root@server2 ~]# tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
yum install -y perl
安装顺序:common→libs→client→server
rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
systemctl start mysqld
[root@server2 ~]# ps -ef | grep mysqld mysql 1199 1 0 06:09 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid [root@server2 ~]# netstat -lntup | grep mysqld tcp6 0 0 :::3306 :::* LISTEN 1199/mysqld
grep 'temporary password' /var/log/mysqld.log
[root@server2 ~]# grep 'temporary password' /var/log/mysqld.log 2021-09-09T22:09:29.134740Z 1 [Note] A temporary password is generated for root@localhost: 4=4kaOLqkgtl
mysql -u root -p'4=4kaOLqkgtl'
[root@server2 ~]# mysql -u root -p'4=4kaOLqkgtl' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.30 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
set global validate_password_policy=0;
set global validate_password_length=4;
set password for root@localhost=password('1234'); flush privileges;
grant all privileges on *.* to 'root'@'%' identified by '1234' with grant option; flush privileges;
修改配置文件 /etc/my.cnf
添加如下配置
[mysqld] character-set-server=utf8 [client] default-character-set=utf8 [mysql] default-character-set=utf8
systemctl restart mysqld