WordPress网站动漫你在,wordpress泽七,公司logo 标志 图案,网站下面版权代码mysql总共有三种安装方式#xff0c;源代码安装#xff0c;二进制安装和源安装。这次写的是二进制安装#xff0c;对其他两种方式不予讨论。关闭selinux和防火墙上课的时候#xff0c;老师说过这是重中之重#xff0c;一定要先关闭selinux和iptables。如果不关闭这两个源代码安装二进制安装和源安装。这次写的是二进制安装对其他两种方式不予讨论。关闭selinux和防火墙上课的时候老师说过这是重中之重一定要先关闭selinux和iptables。如果不关闭这两个可能会出现莫名其妙的错误所以还是关闭的好。[rootmysql_master mysql]# vi /etc/selinux/config# This file controls the state of SELinux on the system.# SELINUX can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUXdisabled# SELINUXTYPE can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPEtargeted把SELINUX赋值为disabled就可以了,修改文件以后是需要重启的。再用getenforce来查看是否修改成功。[rootmysql_master mysql]# getenforceDisabled先临时关闭防火墙再永久关闭防火墙[rootmysql_master mysql]# service iptables stopiptables: Setting chains to policy ACCEPT: filter [ OK ]iptables: Flushing firewall rules: [ OK ]iptables: Unloading modules: [ OK ][rootmysql_master mysql]# chkconfig iptables off下载mysql二进制安装包安装mysql之前首先就要确定自己想要用什么分支什么版本的mysql了这里我使用的mysql官方的5.6.29版本.这里还有别的选择例如percona分支和mariadb分支。好多人都推荐percona分支。[rootmysql_master Downloads]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz下载完是这样一个文件[rootmysql_master Downloads]# lsmysql-5.6.29-linux-glibc2.5-x86_64.tar.gz创建用户组和data目录因为只是为了学习安装。所以没有创建其他的目录只是一个data目录。创建mysql用户并不是为了登录主机的而是单纯为了给目录和文件赋权限表明这些是mysql用户的所以在创建用户的使用使用了-r-s /bin/false 来防止某些人使用这个用户登录主机。[rootmysql_master]# groupadd mysql[rootmysql_master]# useradd -r -g mysql -s /bin/false mysql[rootmysql_master]# cd /[rootmysql_master]# mkdir data[rootmysql_master]# chown -R mysql:mysql /data解压mysql二进制压缩文件并且初始化data目录解压mysql二进制压缩文件到安装目录我选择/opt/mysql你可以选择其他的,还要先修改一个mysql配置文件并且进行简单的配置。解压缩出来的目录里面有这个文件的范本的。只需要拷贝和修改一下就可以了。我的配置范本在/opt/mysql/support-files下面文件名为my-default.cnf修改一下并且cp到/etc/my.cnf[rootmysql_master Downloads]# tar -zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz[rootmysql_master Downloads]# cp -a mysql-5.6.29-linux-glibc2.5-x86_64 /opt/mysql[rootmysql_master Downloads]# cd /opt/mysql/support-files[rootmysql_master support-files]# vi ./my-default.cnf /etc/my.cnf把文件配置成为下面这样就可以了当然这是最简单的配置只是为了演示安装而已。配置项为basedirdatadiruser三项。# For advice on how to change settings please see# *** DO NOT EDIT THIS FILE. Its a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL.[mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required.basedir /opt/mysqldatadir /datauser /data# port .....# server_id .....# socket .....# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size 128M# sort_buffer_size 2M# read_rnd_buffer_size 2Msql_modeNO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES[rootmysql_master support-files]# cp my-default.cnf /etc/my.cnf初始化/data目录[rootmysql_master mysql]# ./scripts/mysql_install_db --defaults-file /etc/my.cnf启动mysql进行连接测试[rootmysql_master mysql]# ./bin/mysqld --defaults-file /etc/my.cnf [rootmysql_master mysql]# ./bin/mysql -S /tmp/mysql.sockWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.6.29 MySQL Community Server (GPL)Copyright (c) 2000, 2016, 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到这里mysql的二进制安装就全部结束了。