本文共 2140 字,大约阅读时间需要 7 分钟。
操作系统:CentOS release 6.8 (Final)
应用软件:mysql-5.6.40-linux-glibc2.12-x86_641、关闭Linux防火墙
[root@Paul ~]# service iptables stop[root@Paul ~]# chkconfig iptables off2、 关闭SELINUX[root@Paul ~]# setenforce 0[root@Paul ~]# vim /etc/selinux/config修改/etc/selinux/config 文件将SELINUX=enforcing改为SELINUX=disable3、查看已安装版本[root@node2 ~]# rpm -qa | grep mysqlmysql-libs-5.1.73-7.el6.x86_644、删除旧版本[root@node2 ~]# yum remove -y mysql-libs-5.1.73-el6.x86_641、在mysql官网https://www.mysql.com/downloads/,依次点击下载合适版本,如下图:
2、下载安装包
[root@Paul ~]# wget1、添加mysql用户和组
[root@Paul ~]# groupadd -g 306 mysql[root@Paul ~]# useradd -g 306 -u 306 -s/sbin/nologin -M mysql2、创建mysql安装目录和数据库文件存放目录
[root@Paul ~]# mkdir /data/mysql –pv[root@Paul ~]# mkdir /usr/local/mysql3、解压原码
[root@node2 ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz解压文件拷贝到/usr/local/mysql下[root@node2 ~]# cp -a mysql-5.6.40-linux-glibc2.12-x86_64/* /usr/local/mysql4、修改属组、属主[root@Paul local]# chown -R mysql.mysql /usr/local/mysql[root@Paul ~]# chown -R mysql.mysql /data/mysql5、修改配置文件
[root@Paul mysql]# cp support-files/my-default.cnf /etc/my.cnf[root@Paul mysql]# vim /etc/my.cnfbasedir = /usr/local/mysqldatadir = /data/mysqlport = 3306socket = /tmp/mysql.socklog-error= /usr/local/mysql/data/error.logpid-file = /usr/local/mysql/data/mysql.pid6、初始化系统数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql--basedir=/usr/local/mysql7、配置mysqld服务
root@Paul ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld[root@Paul ~]# chmod +x /etc/rc.d/init.d/mysqld[root@Paul ~]# chkconfig --add mysqld[root@Paul ~]# chkconfig mysqld on[root@Paul ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf[root@Paul ~]# ln -sv /usr/local/mysql/include /usr/include/mysqld8、设置mysql环境变量
[root@Paul ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh[root@Paul ~]# source /etc/profile.d/mysql.sh9、配置帮助文档
[root@Paul ~]# vim /etc/man.configMANPATH /usr/local/mysql/man10、启动mysqld服务[root@Paul ~]# service mysqld start转载于:https://blog.51cto.com/437549/2114513