CentOS7.4下MySQL5.7.28二进制方式安装
发表于:2025-11-11 作者:千家信息网编辑
千家信息网最后更新 2025年11月11日,Linux系统版本:CentOS7.4MySQL版本:5.7.28在Linux平台有RPM包、二进制包、源码包3中安装方式,这一篇文章主要是以二进制包为例来介绍如何在Linux平台下进行MySQL的安
千家信息网最后更新 2025年11月11日CentOS7.4下MySQL5.7.28二进制方式安装
Linux系统版本:CentOS7.4
MySQL版本:5.7.28
在Linux平台有RPM包、二进制包、源码包3中安装方式,这一篇文章主要是以二进制包为例来介绍如何在Linux平台下进行MySQL的安装。
下载地址:
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
具体安装步骤如下:
(1)首先卸载mariadb,不然后面会和安装mysql需要的库冲突:
[root@localhost ~]# rpm -qa | grep mariadbmariadb-libs-5.5.56-2.el7.x86_64[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64(2)用root用户登录系统,增加mysql用户和组,数据库安装在此用户下:
[root@localhost ~]# groupadd mysql[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql(3)准备数据目录
以/app/data为例,建议使用逻辑卷
[root@localhost ~]# mkdir -p /app/data[root@localhost ~]# chown mysql.mysql /app/data/[root@localhost ~]# chmod 750 /app/data(4)准备二进制文件:
[root@localhost ~]# tar xvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /usr/local/root@localhost ~]# cd /usr/local[root@localhost local]# ln -sv mysql-5.7.28-linux-glibc2.12-x86_64 mysql'mysql' -> 'mysql-5.7.28-linux-glibc2.12-x86_64'(5)初始化MySQL:
[root@localhost ~]# cd /usr/local/mysql[root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/data2019-11-03T09:47:18.263716Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2019-11-03T09:47:19.059462Z 0 [Warning] InnoDB: New log files created, LSN=457902019-11-03T09:47:19.140866Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2019-11-03T09:47:19.207569Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ed1cd8ec-fe1e-11e9-8c9c-000c29f8617a.2019-11-03T09:47:19.209181Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2019-11-03T09:47:19.646366Z 0 [Warning] CA certificate ca.pem is self signed.2019-11-03T09:47:20.056792Z 1 [Note] A temporary password is generated for root@localhost: rY-6f??#!其中--basedir mysql基础目录 --datadir mysql数据存放目录,并创建了root用户的临时密码:rY-6f??#!
[root@localhost mysql]# bin/mysql_ssl_rsa_setup2019-11-03 23:09:55 [ERROR] Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. Supplied value : /usr/local/mysql/data[root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/app/data命令后面不加参数报错,加了--datadir后不报错
(7)编辑配置文件,保存退出:
[root@localhost mysql]# vim /etc/my.cnf[mysqld]# GENERALdatadir=/app/datasocket=/app/data/mysql.sockuser=mysqldefault-storage-engine=InnoDB[mysqld_safe]log-error=/app/data/mysql-error.logpid-file=/app/data/mysqld.pid[client]socket=/app/data/mysql.sock(8)启动MySQL:
[root@localhost mysql]# bin/mysqld_safe --user=mysql &(9)配置环境变量:
[root@localhost ~]# vim /etc/profile
#添加下面一行
export PATH=$PATH:/usr/local/mysql/bin
[root@localhost ~]# source /etc/profile
(10)设置开机启动:
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql[root@localhost mysql]# vim /etc/init.d/mysqlbasedir=/usr/local/mysqldatadir=/app/data[root@localhost mysql]# chkconfig --add mysql(11)测试登录成功:
[root@localhost ~]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.28Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>(12)修改MySQL的root密码为root123456,并重新登录:
mysql> set password = PASSWORD('root123456');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> exit;Bye[root@localhost ~]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.7.28 MySQL Community Server (GPL)Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>(13)管理账户以及授权:
mysql> grant all privileges on *.* to 'sunan'@'%' identified by 'sunan123456';Query OK, 0 rows affected, 1 warning (0.00 sec)上面是创建用户:sunan 密码:sunan123456 all privilegs:所有权限 .:对所有的数据库的所有表 %:从任何主机连接
用户
数据
二进制
密码
目录
登录
平台
数据库
文件
版本
系统
准备
配置
方式
成功
一行
主机
参数
变量
命令
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
学校如何开展网络安全宣传
日本电商怎么选服务器
网络安全教育竞赛活动
企业服务器管理细则
直销软件开发哪家值得信赖
网络安全认证 资质
福州网络技术服务平台
华为服务器的油是什么原因
微谱数据库昆明理工大学
xampp数据库备份
东营采购软件开发服务
网络安全知识进企业沙龙
校园网络安全情景剧
电子商务后台软件开发
韩国n号房属于网络安全吗
国外有名的技术数据库
转回原服务器多久可以登记
网络安全培训机构排名常州
腾讯云轻量级服务器安全组
千方百剂iii数据库连接
学校网络安全会议内容
艾欧尼亚服务器能有多少人
数据库log文件巨大
人教版四年级网络安全优质课
江苏定制软件开发价格实惠
江苏服务器电源专卖店
水云清网络技术
电脑服务器一直显示拒绝访问
临汾软件开发厂家报价
我的世界初心宝可梦服务器下载