一、准备环境:
1.CentOS7.x版本Linux系统
这里选用CentOS7.8(2003)版本
下载地址:http://isoredirect.centos.org/centos/7/isos/x86_64/
2.MySQL5.7.x数据库版本
这里选用MySQL_5.7.31版本
下载地址:https://dev.mysql.com/downloads/mysql/
二、部署前操作:
1.部署CentOS7
2.配置yum源
3.使用FileZilla工具上传MySQL安装包到CentOS7.8系统上
FileZilla Client版本具体配置yum源和上传MySQL包可以参考百度,这里不做详述(请见谅!!!!)
三、部署MySQL环境:
1.将MySQL放到指定的目录中并解压
[root@mysql ~]# ls
anaconda-ks.cfg mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar software
[root@mysql ~]# cd software/
[root@mysql software]# ls
mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar
[root@mysql software]# tar xf mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar
[root@mysql software]# ls
mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar mysql-community-devel-5.7.31-1.el7.x86_64.rpm mysql-community-embedded-devel-5.7.31-1.el7.x86_64.rpm mysql-community-server-5.7.31-1.el7.x86_64.rpm
mysql-community-client-5.7.31-1.el7.x86_64.rpm mysql-community-embedded-5.7.31-1.el7.x86_64.rpm mysql-community-libs-5.7.31-1.el7.x86_64.rpm mysql-community-test-5.7.31-1.el7.x86_64.rpm
mysql-community-common-5.7.31-1.el7.x86_64.rpm mysql-community-embedded-compat-5.7.31-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.31-1.el7.x86_64.rpm
2.查看原系统之中是否存在MySQL或者是Mariadb后卸载(我的没有安装MySQL只需要卸载Mariadb)
[root@mysql ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
[root@mysql ~]# rpm -e mariadb-libs-5.5.65-1.el7.x86_64
error: Failed dependencies: ----> 此处报错是因为有依赖,必须先卸载postfix-2:2.10.1-9.el7.x86_64,才可以卸载mariadb
libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-9.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-9.el7.x86_64
[root@mysql ~]# rpm -e postfix-2:2.10.1-9.el7.x86_64
[root@mysql ~]# rpm -e mariadb-libs-5.5.65-1.el7.x86_64
3.配置mysql仓库
[root@mysql ~]# vi /etc/yum.repos.d/MySQL-Media.repo
[MySQL-Media]
name=mysql
baseurl=file:///root/software
gpgcheck=0
enabled=1
建立MySQL源仓库
[root@mysql ~]# createrepo /root/software/
Spawning worker 0 with 5 pkgs
Spawning worker 1 with 5 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@mysql ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: MySQL-Media yum-source
Cleaning up list of fastest mirrors
[root@mysql ~]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
MySQL-Media | 2.9 kB 00:00:00
yum-source | 3.6 kB 00:00:00
(1/7): MySQL-Media/filelists_db | 75 kB 00:00:00
(2/7): MySQL-Media/other_db | 3.5 kB 00:00:00
(3/7): MySQL-Media/primary_db | 12 kB 00:00:00
(4/7): yum-source/group_gz | 153 kB 00:00:00
(5/7): yum-source/primary_db | 3.3 MB 00:00:00
(6/7): yum-source/filelists_db | 3.3 MB 00:00:00
(7/7): yum-source/other_db | 1.3 MB 00:00:00
Metadata Cache Created
4.开始安装MySQL
注意:只安装包里这个名字的安装包(mysql-community-server)
[root@mysql ~]# yum install -y mysql-community-server mysql-community-devel mysql-community-libs mysql-community-common
最后提示:Complete!表示安装成功,如果出现Error等报错信息请参考百度解决方案
MySQL为默认设置,与企业级设置不同,请注意,本笔记进学习交流。
5.启动MySQL服务
[root@mysql ~]# systemctl start mysqld
启动成功并查看MySQL状态信息6.修改MySQL初始密码
最后为初始密码 表示已经成功登陆注:如果担心密码暴露,可以使用以下命令进行登录
输入密码登录(安全较高) 此处报错是因为密码过于简单的问题导致(请设置加强密码:大小写+数字+字符)扩展:
如果想设置简单密码,操作如下:
此时已经关闭了强密码设置 此时可以设置弱密码退出MySQL终端命令:
\q可退出mysql>命令行以上是如何部署MySQL5.7环境
接下来设置自动启动MySQL项
[root@mysql ~]# systemctl enable mysqld
网友评论