RHEL 7.2如何安装二进制MySQL 5.7.18


这篇文章给大家分享的是有关RHEL 7.2如何安装二进制MySQL 5.7.18的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。环境:Red Hat Enterprise Linux Server release 7.2 (Maipo)mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz安装需求:libaioMySQL 5.7.19 and later 需要安装libnuma,由于本次测试为5.7.18,不需要安装libnuma.如之前安装过MySQL,清除一下目录和文件/etc/my.cnfor the/etc/mysqlrhel7以后需要取消RemoveIPC限制[root@rhelb mysql]# vi /etc/systemd/logind.conf#RemoveIPC=yes ->RemoveIPC=no检查软件包是否安装[root@rhelb mysql]# rpm -qa | grep libaio关闭防火墙[root@rhelb yum.repos.d]# vi /etc/sysconfig/selinuxSELINUX=enforcing->SELINUX=disabled关闭系统THP,rhel7以后和之前关闭THP文件有变化,rhel7及以后关闭方式如下:[root@rhelb yum.repos.d]# cat /sys/kernel/mm/transparent_hugepage/enabled[always] madvise never在quiet后添加transparent_hugepage=never[root@rhelb yum.repos.d]# cat /etc/default/grubGRUB_TIMEOUT=5GRUB_DISTRIBUTOR=”$(sed ‘s, release .*$,,g’ /etc/system-release)”GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT=”console”GRUB_CMDLINE_LINUX=”crashkernel=auto rhgb quiet
transparent_hugepage=never”GRUB_DISABLE_RECOVERY=”true”添加后重启主机[root@rhelb yum.repos.d]# cat /sys/kernel/mm/transparent_hugepage/enabledalways madvise [never]配置yum源,rhel7以后,新建一个新的yum资料库[root@rhelb mysql]#mount /dev/sr0 /mnt[root@rhelb yum.repos.d]# ls -lrttotal 8-rw-r–r–. 1 root root 91 Aug 16 23:11 rhel.repo-rw-r–r–. 1 root root 358 Aug 16 23:12 redhat.repo[root@rhelb yum.repos.d]# more /etc/yum.repos.d/rhel.repo[rhel7_server]name=added from: file:///rhel7/dvdbaseurl=file:///mntenabled=1gpgcheck=0安装软件包:[root@rhelb mysql]# yum -y install libaio.x86_64……Installed: libaio.x86_64 0:0.3.109-13.el7 Complete!MySQL二进制目录说明:解压软件:
[root@rhelb soft]# tar -xzvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz[root@rhelb soft]# mv mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql创建相关用户:[root@rhelb mysql]# groupadd mysql[root@rhelb mysql]# useradd -r -g mysql -s /bin/false mysql[root@rhelb mysql]# cd /usr/local[root@rhelb local]# mkdir /data[root@rhelb local]# chown -R mysql:mysql /usr/local/mysql/[root@rhelb local]# chown -R mysql:mysql /data/[root@rhelb local]# chmod 750 /data/初始化数据库:
查看mysqld参数:
root@rhelb mysql]# bin/mysqld –verbose –help |moremysqld: Can’t change dir to ‘/var/lib/mysql/’ (Errcode: 2 – No such file or directory)bin/mysqld Ver 5.7.18 for linux-glibc2.5 on x86_64 (MySQL Community Server (GPL))Copyright (c) 2000, 2017, 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.Starts the MySQL database server.Usage: bin/mysqld [OPTIONS]Default options are read from the following files in the given order:/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnfThe following groups are read: mysqld server mysqld-5.7The following options may be given as the first argument:……[root@rhelb mysql]# ./bin/mysqld –initialize –user=mysql –basedir=/data/ –datadir=/data/2018-08-21T09:11:34.367385Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).2018-08-21T09:11:34.367604Z 0 [ERROR] Can’t find error-message file ‘/data/share/errmsg.sys’. Check error-message file location and ‘lc-messages-dir’ configuration directive.2018-08-21T09:11:34.632615Z 0 [Warning] InnoDB: New log files created, LSN=457902018-08-21T09:11:34.705037Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2018-08-21T09:11:34.997455Z 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: 33b8197c-a522-11e8-83a6-080027073030.2018-08-21T09:11:35.001885Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.2018-08-21T09:11:35.004186Z 1 [Note] A temporary password is generated for root@localhost: kdivr2ax2P,Kroot初始化密码kdivr2ax2P,K[root@rhelb mysql]# ls -lrt /data/total 110628-rw-r—– 1 mysql mysql 50331648 Aug 21 05:11 ib_logfile1-rw-r—– 1 mysql mysql 56 Aug 21 05:11 auto.cnfdrwxr-x— 2 mysql mysql 8192 Aug 21 05:11 performance_schemadrwxr-x— 2 mysql mysql 4096 Aug 21 05:11 mysqldrwxr-x— 2 mysql mysql 8192 Aug 21 05:11 sys-rw-r—– 1 mysql mysql 419 Aug 21 05:11 ib_buffer_pool-rw-r—– 1 mysql mysql 50331648 Aug 21 05:11 ib_logfile0-rw-r—– 1 mysql mysql 12582912 Aug 21 05:11 ibdata1配置ssl,会话安全方面考虑,如不需要可以不配置
[root@rhelb mysql]# bin/mysql_ssl_rsa_setupGenerating a 2048 bit RSA private key……………………………+++…+++writing new private key to ‘ca-key.pem’—–Generating a 2048 bit RSA private key………………………………………………………………..+++.+++writing new private key to ‘server-key.pem’—–Generating a 2048 bit RSA private key…………………………+++…………………………………………………………+++writing new private key to ‘client-key.pem’配置参数文件,如果不配置[client]客户端连接时提示/tmp/socket.sock[root@rhelb etc]# vi /etc/my.cnf[mysqld]port = 3306pid-file = /data/mysql3306.piddatadir = /data/socket = /data/mysql3306.sockslow_query_log_file = /data/slow.loglog-error = /data/error.log[client]socket = /data/mysql3306.sock MySQL取消安全隐患:a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效root@rhelb mysql]# bin/mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root:Error: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)[root@rhelb mysql]# bin/mysql_secure_installation -S /data/mysql3306.sockSecuring the MySQL server deployment.Enter password for user root:Error: Access denied for user ‘root’@’localhost’ (using password: NO)[root@rhelb mysql]# bin/mysql_secure_installation -S /data/mysql3306.sockSecuring the MySQL server deployment.Enter password for user root:
The existing password for the user account root has expired. Please set a new password.New password:Re-enter new password:VALIDATE PASSWORD PLUGIN can be used to test passwordsand improve security. It checks the strength of passwordand allows the users to set only those passwords which aresecure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: YThere are three levels of password validation policy:LOW Length >= 8MEDIUM Length >= 8, numeric, mixed case, and special charactersSTRONG Length >= 8, numeric, mixed case, special characters and dictionary filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1Using existing password for root.Estimated strength of the password: 100Change the password for root ? ((Press y|Y for Yes, any other key for No) : … skipping.By default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : YSuccess.Normally, root should only be allowed to connect from’localhost’. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : YSuccess.By default, MySQL comes with a database named ‘test’ thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y- Dropping test database…Success.- Removing privileges on test database…Success.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : YSuccess.All done!
配置服务启动:
[root@rhelb mysql]# cp support-files/mysql.server /etc/init.d/[root@rhelb mysql]# service mysql.server startStarting MySQL. SUCCESS![root@rhelb mysql]# ps -ef | grep mysqlroot 34开发云主机域名86 1 0 05:51 pts/2 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe –datadir=/data/ –pid-file=/data/mysql3306.pidmysql 3653 3486 6 05:51 pts/2 00:00:00 /usr/local/mysql/bin/mysqld –basedir=/usr/local/mysql –datadir=/data –plugin-dir=/usr/local/mysql/lib/plugin –user=mysql –log-error=/data/error.log –pid-file=/data/mysql3306.pid –socket=/data/mysql3306.sock –port=3306root 3685 2711 0 05:51 pts/2 00:00:00 grep –color=auto mysql[root@rhelb etc]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 4Server version: 5.7.18 MySQL Community Server (GPL)Copyright (c) 2000, 2017, 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> status;————–mysql Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86_64) using EditLine wrapperConnection id: 4Current database:Current user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile: ”Using delimiter: ;Server version: 5.7.18 MySQL Community Server (GPL)Protocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: utf8Conn. characterset: utf8UNIX socket: /data/mysql3306.sockUptime: 12 secThreads: 1 Questions: 6 Slow queries: 0 Opens: 105 Flush tables: 1 Open tables: 98 Queries per second avg: 0.500感谢各位的阅读!关于“RHEL 7.2如何安装二进制MySQL 5.7.18”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

相关推荐: MYsql锁与索引的关系

这篇文章主要讲解了“MYsql锁与索引的关系”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“MYsql锁与索引的关系”吧!mysql innodb的锁是通过锁索引来实现的。select for update . …

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 06/23 16:28
下一篇 06/23 16:29

相关推荐