这篇文章主要介绍“KVM MYSQL 5.7单机FOR OEL7.5安装文档的方法是什么”,在日常操作中,相信很多人在KVM MYSQL 5.7单机FOR OEL7.5安装文档的方法是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”KVM MYSQL 5.7单机FOR OEL7.5安装文档的方法是什么”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

1. KVM MYSQL 5.7 单机 FOR OEL7.5 通常安装文档2. 安装流程2.1. 确定平台版本和机器位数。

确定当前MYSQL版本对应各种操作系统 平台是否支持。

2.2. 下载对应版本2.2.1. 下载二进制安装包

 官方网站
 http://dev.mysql.com/downloads/mirrors.html.
 进入后可以选择对应的版本

NOTE:
tar.gz tar.xz 为二进制安装。
RPM 为rpm 安装包。
deb 为 deband linux 安装包.
PKG 为mac 文件安装包。

2.2.2. 下载yum 源配置包(社区版)

https://dev.mysql.com/downloads/repo/yum/

2.2.3. 下载源码编译

 源码现目前在GIT 上托管。

2.3. 验证下载后文件是否正确

LINUX AND WINDOWS MD5 验证

shell>md5summysql-standard-8.0.13-linux-i686.tar.gzaaab65abbec64d5e907dcd41b8699945mysql-standard-8.0.13-linux-i686.tar.gz

shell>md5.exemysql-installer-community-8.0.13.msiaaab65abbec64d5e907dcd41b8699945mysql-installer-community-8.0.13.msi

RPM 包验证

shell>rpm--checksigMySQL-server-8.0.13-0.linux_glibc2.5.i386.rpmMySQL-server-8.0.13-0.linux_glibc2.5.i386.rpm:md5gpgOK3. 二进制部署

NOTE:
使用二进制安装这种模式不同于yum 安装自动分析相关依赖包。必须首先移除mariadb或者以前的安装过mysql 的配置文件。例如/etc/my.conf.

卸载mariadb

shell>yumremovemariadb*

安装依赖包

shell>yumsearchlibaio#searchforinfoshell>yuminstalllibaio#installlibrary3.1. 安装目录说明3.2. 安装MySQL3.2.1. 创建MySQL用户和组

shell>groupaddmysqlshell>useradd-r-gmysql-s/bin/falsemysql3.2.2. 解压软件

shell>cd/usr/localshell>tarzxvf/path/to/mysql-VERSION-OS.tar.gzshell>gunzip</path/to/mysql-VERSION-OS.tar.gz|tarxvf-3.2.3. 创建新的链接文件到真实目录

shell>ln-sfull-path-to-mysql-VERSION-OSmysql3.2.4. 设置环境变量

shell>exportPATH=$PATH:/usr/local/mysql/bin3.2.5. 配置启动目录

shell>cdmysqlshell>mkdirmysql-filesshell>chownmysql:mysqlmysql-filesshell>chmod750mysql-files3.2.6. 初始化数据库

shell>bin/mysqld--initialize--user=mysql3.2.6.1. 初始化数据库两种方式

shell>bin/mysqld--initialize--user=mysqlshell>bin/mysqld--initialize-insecure--user=mysql

NOTE:

两种初始化方式第一种必须强制使用密码登录
第二种方式可以使用跳过密码
shell> mysql -u root --skip-password
然后更改对应密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
在mysql 8.0 默认加密的密码已经改了。现在默认使用caching_sha2_password 加密方式。
如果还需使用默认的mysql_native_password 加密方式的话使用默认 模式。
初始化的时候,默认路径为/usr/local/mysql

3.2.6.2. 更改默认路径

如果要改变安装目录使用以下目录:

shell>bin/mysqld--initialize--user=mysql--basedir=/opt/mysql/mysql--datadir=/opt/mysql/mysql/data

配置文件

[mysqld]basedir=/opt/mysql/mysqldatadir=/opt/mysql/mysql/data

使用配置文件指定位置:

范例

shell>bin/mysqld--initialize-insecure--user=mysql\--basedir=/app/mysql\--datadir=/app/mysql/mysql-files

输出日志:

[root@mysql1mysql]#bin/mysqld--initialize-insecure--user=mysql\>--basedir=/app/mysql\>--datadir=/app/mysql/mysql-files2018-09-28T16:18:32.178288Z0[System][MY-013169][Server]/app/mysql-commercial-8.0.12-el7-x86_64/bin/mysqld(mysqld8.0.12-commercial)initializingofserverinprogressasprocess53282018-09-28T16:18:46.268910Z5[Warning][MY-010453][Server]root@localhostiscreatedwithanemptypassword!Pleaseconsiderswitchingoffthe--initialize-insecureoption.2018-09-28T16:18:57.082553Z0[System][MY-013170][Server]/app/mysql-commercial-8.0.12-el7-x86_64/bin/mysqld(mysqld8.0.12-commercial)initializingofserverhascompleted3.2.7. 创建安全连接3.2.7.1. 说明FormatDescription—datadirPath to data directory—helpDisplay help message and exit—suffixSuffix for X509 certificate Common Name attribute—uidName of effective user to use for file permissions—verboseVerbose mode—versionDisplay version information and exit3.2.7.2. 默认目录

shell>bin/mysql_ssl_rsa_setup3.2.7.3. 指定目录

bin/mysql_ssl_rsa_setup--datadir=/app/mysql/mysql-files/

———————————到此安装完毕—————————————————-

4. YUM 源安装

a. 去下载MySQL 的repo 文件:http://dev.mysql.com/downloads/repo/yum/

wgethttps://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

b. 选择对应操作系统版本的
c. 本地安装

shell>sudoyumlocalinstallplatform-and-version-specific-package-name.rpm

EL6-based system

shell>sudoyumlocalinstallmysql80013-community-release-el6-{version-number}.noarch.rpm

EL7-based system:

shell>sudoyumlocalinstallmysql80013-community-release-el7-{version-number}.noarch.rpm

Fedora 28:

shell>sudodnflocalinstallmysql80013-community-release-fc28-{version-number}.noarch.rpm

Fedora 27:

shell>sudodnflocalinstallmysql80013-community-release-fc27-{version-number}.noarch.rpm

范例:

yumlocalinstallmysql80-community-release-el7-1.noarch.rpm

查看已经启用MySQL 源

yumrepolistenabled|grep"mysql.*-community.*"

启用集群安装

mysql-cluster

查看所有mysql 有关的安装源

shell>yumrepolistall|grepmysql

开启对应安装yum源

shell>sudoyum-config-manager--disablemysql57-communityshell>sudoyum-config-manager--enablemysql80-community

例如:
开启集群

shell>sudoyum-config-manager--enablemysql-cluster-7.6-community


安装MYSQL

yuminstallmysql-community-server5. 使用RPM 包安装

说明:

由于企业版只提供二进制和RPM 包方式。。不提供YUM 安装方式。
以下是各个RPM 包的含义:

Package NameSummarymysql-commercial-backupMySQL Enterprise Backup (added in 8.0.11)mysql-commercial-clientMySQL client applications and toolsmysql-commercial-commonCommon files for server and client librariesmysql-commercial-develDevelopment header files and libraries for MySQL database client applicationsmysql-commercial-embedded-compatMySQL server as an embedded library with compatibility for applications using version 18 of the librarymysql-commercial-libsShared libraries for MySQL database client applicationsmysql-commercial-libs-compatShared compatibility libraries for previous MySQL installations; the version of the libraries matches the version of the libraries installed by default by the distribution you are usingmysql-commercial-minimal-debuginfoDebug information for package mysql-commercial-server-minimal; useful when developing applications that use this package or when debugging this packagemysql-commercial-serverDatabase server and related toolsmysql-commercial-server-minimalMinimal installation of the database server and related tools (added in 8.0.0)mysql-commercial-testTest suite for the MySQL server

下载对应版本的RPM 包进行解压

[root@mysql3~]#unzipV979091-01.zipArchive:V979091-01.zipextracting:mysql-commercial-libs-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-embedded-compat-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-test-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-server-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-server-minimal-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-minimal-debuginfo-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-devel-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-client-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-libs-compat-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-common-8.0.12-1.1.el7.x86_64.rpmextracting:mysql-commercial-backup-8.0.12-1.1.el7.x86_64.rpmextracting:README.txt

批量自动安装:自动解决依赖包。使用此命令时注意不要和server_mini 混用。

yuminstallmysql-commercial-*

简易服务端

sudoyuminstallmysql-community-{server,client,common,libs}-*

简易客户端

yuminstallmysql-community-{client,common,libs}-*

目录分布

Files or ResourcesLocationClient programs and scripts/usr/binmysqld server/usr/sbinConfiguration file/etc/my.cnfData directory/var/lib/mysqlError log fileFor RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.logFor SLES: /var/log/mysql/mysqld.logValue of secure_file_priv/var/lib/mysql-filesSystem V init scriptFor RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqldFor SLES: /etc/init.d/mysqlSystemd serviceFor RHEL, Oracle Linux, CentOS or Fedora platforms: mysqldFor SLES: mysqlPid file/var/run/mysql/mysqld.pidSocket/var/lib/mysql/mysql.sockKeyring directory/var/lib/mysql-keyringUnix manual pages/usr/share/manInclude (header) files/usr/include/mysqlLibraries/usr/lib/mysqlMiscellaneous support files (for example, error messages, and character set files)/usr/share/mysql5.1. 安装相关组件

列出开启yum 中所有相关的安装包。,包括未enable 中的源
例如主机上要连接低版本客户端。则需要安装低版本客户端如下:

rpm--oldpackage-ivhmysql-community-libs-5.5.50-2.el6.x86_64.rpm

安装其他软件:到官网下载对应版本安装。

6. 启动和关闭6.1. 使用二进制安装

shell>bin/mysqld_safe--user=mysql&#6.Nextcommandisoptional6.1.1. 拷贝自启动文件

shell>cp/app/mysql/support-files/mysql.server/etc/init.d/6.1.2. 编辑my.cnf 文件

basedir=/app/mysqldatadir=/app/mysql/mysql-files6.1.3. 重载启动项目

systemctldaemon-reload6.1.4. 查看是否启动MySQL

systemctlstatusmysql6.1.5. 开机自启动

NOTE:
由于使用二进制安装,则需要配置chkconfig 。RPM 包不需要

chkconfig--addmysql.serverchkconfigmysql.serveron6.2. 使用yum 源安装6.2.1. 启动MySQL

servicemysqldstartsystemctlstartmysqld6.2.2. 查看是否启动MySQL

systemctlstatusmysqld6.2.3. 开机自启动

systemctlenablemysqldsystemctldisablemysqld6.3. 使用RPM 包安装6.3.1. 启动MySQL

servicemysqldstartsystemctlstartmysqld6.3.2. 查看是否启动MySQL

systemctlstatusmysqld6.3.3. 开机自启动

systemctlenablemysqldsystemctldisablemysqld7. MySQL 启动后诊断7.1. 查看日志

tailhost_name.err7.2. 选择驱动


默认为InnoDB

7.3. 确认数据文件位置是否合适7.4. 查看所有配置参数和所有的环境变量

mysqld--basedir=/app/mysql--verbose–help|more7.5. 配置文件环境变量

mysqladminvariables-uroot-pmysqladmin-hhost_namevariables-uroot-p8. 测试MySQL

检查mysql 是否正常运行

mysqladminversion

检查配置变量值

mysqladminvariables

检查是否能登陆

mysqladmin-uroot-pversion

关闭mysql 服务

mysqladmin-urootshutdown

显示mysql 数据库

mysqlshow

显示某个数据库中的表

mysqlshowmysql

shell 界面查询表数据

mysql-e"SELECTUser,Host,pluginFROMmysql.user"mysql

NOTE:

以上命令成功执行后则mysql 数据正常。

9. 账户安全9.1. yum 源安装

临时密码:

grep'temporarypassword'/var/log/mysqld.log

登录:

mysql-uroot-p

更改密码:

ALTERUSER'root'@'localhost'IDENTIFIEDBY'MyNewPass4!';

由于密码复杂度有相关要求:但是测试不需要则

mysql>SHOWVARIABLESLIKE'validate_password%';+--------------------------------------+--------+|Variable_name|Value|+--------------------------------------+--------+|validate_password.check_user_name|ON||validate_password.dictionary_file|||validate_password.length|8||validate_password.mixed_case_count|1||validate_password.number_count|1||validate_password.policy|MEDIUM||validate_password.special_char_count|1|+--------------------------------------+--------+7rowsinset(0.01sec)setGLOBALvalidate_password.policy=0;设置密码长度setGLOBALvalidate_password.length=3;

设置密码复杂度为低。更方便测试。

ALTERUSER'root'@'localhost'IDENTIFIEDBY'1234';9.2. 二进制安装

使用mysqld —insecure初始化后的密码更改

mysql-uroot-pALTERUSER'root'@'localhost'IDENTIFIEDBY'new_password';

如果使用mysqld —initialize-insecure 进行初始化
则:

mysql-uroot--skip-password


更改密码:

ALTERUSER'root'@'localhost'IDENTIFIEDBY'123'9.3. RPM 包安装

临时密码:

grep'temporarypassword'/var/log/mysqld.log

登录:

mysql-uroot-p

更改密码:

ALTERUSER'root'@'localhost'IDENTIFIEDBY'MyNewPass4!';

由于密码复杂度有相关要求:但是测试不需要则

mysql>SHOWVARIABLESLIKE'validate_password%';+--------------------------------------+--------+|Variable_name|Value|+--------------------------------------+--------+|validate_password.check_user_name|ON||validate_password.dictionary_file|||validate_password.length|8||validate_password.mixed_case_count|1||validate_password.number_count|1||validate_password.policy|MEDIUM||validate_password.special_char_count|1|+--------------------------------------+--------+7rowsinset(0.01sec)mysql>setGLOBALvalidate_password.policy=0;mysql>setGLOBALvalidate_password.length=3;

设置密码复杂度为低。更方便测试。

ALTERUSER'root'@'localhost'IDENTIFIEDBY'1234';10. 附录10.1. 忘记root 密码

方法1:

kill`cat/mysql-data-directory/host_name.pid`

把以下语句保存到文件中

ALTERUSER'root'@'localhost'IDENTIFIEDBY'MyNewPass';

例如:/root/mysql-init

开始改变密码

mysqld--init-file=/home/me/mysql-init&

mysql 服务会自动启动。

然后删除保存密码的文件。
方法2:
添加my.cnf 选项

skip-grant-tables:


重启MySQL

更改密码

mysqlupdateusersetpassword=password("new_pass")whereuser="root";FLUSHPRIVILEGES;ALTERUSER'root'@'localhost'IDENTIFIEDBY'MyNewPass';

到此,关于“KVM MYSQL 5.7单机FOR OEL7.5安装文档的方法是什么”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!