https://downloads.mysql.com/archives/community/ 只需下载最新版图示4个包就可以了
一般centos7默认安装了mariadb,这里把它卸载。
查看:[root@cm1 bin]# rpm -qa|grep mariadb 卸载:[root@cm1 bin]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64 3.2 安装mysql5.7所需要的依赖 [root@cm1 ]# yum install libaio [root@cm1 ]# yum install perl [root@cm1 ]# yum install net-tools启动mysql, active(running)代表启动成功
[root@cm1 mysql]# systemctl start mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since 四 2020-10-01 01:19:18 CST; 1min 10s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 36299 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 36245 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 36303 (mysqld) CGroup: /system.slice/mysqld.service └─36303 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 4.3 修改密码 查看临时密码: [root@cm1 mysql]# grep password /var/log/mysqld.log 2020-09-30T17:19:14.938108Z 1 [Note] A temporary password is generated for root@localhost: EC5?kvs)Es14用临时密码登录mysql
[root@cm1 mysql]# mysql -uroot -p'EC5?kvs)Es14' mysql>修改密码校验等级,如无必要,请跳过此步骤:
mysql> set global validate_password_policy=LOW; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_length=6; Query OK, 0 rows affected (0.00 sec)修改成新的密码
mysql> set password = password("123456"); 4.4 开启远程连接,允许远程连接数据库 mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; 4.5 配置mysql的配置文件my.cnf(如无必要,请跳过此步骤) 打开配置文件my.cnf [root@cm1 ]# vi /etc/my.cnf在[mysqld]下面配置几行
lower_case_table_names=1 #配置表名不区分大小写 1:不区分大小写 0:区分大小写 这行必须配置 默认表名是区分大小写的,不利于开发 character-set-server=utf8 #设置为默认编码为utf8 init_connect='SET NAMES utf8' max_connections=1024 #设置最大连接数重启mysql 重启配置才能生效
[root@cm1 ]# systemctl restart mysqld至此,安装完成。