1.创建安装目录:
[root@db01 ~]# mkdir /application2.下载二进制安装包:wget https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz3.解压二进制包:
[root@db01 ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz4.移动解压目录
[root@db01 ~]# mv mysql-5.6.40-linux-glibc2.12-x86_64 /application/mysql-5.6.405.做MySQL软连接
[root@db01 scripts]# ln -s /application/mysql-5.6.40/ /application/mysql6.创建MySQL用户
[root@db01 ~]# useradd mysql -s /sbin/nologin -M7.进入配置文件及启动脚本目录
[root@db01 ~]# cd /application/mysql-5.6.40/support-files8.拷贝配置文件到/etc/my.cnf
[root@db01 support-files]# cp my-default.cnf /etc/my.cnf9.拷贝启动脚本
[root@db01 support-files]# cp mysql.server /etc/init.d/mysqld10.初始化MySQL
[root@db01 scripts]# cd /application/mysql-5.6.40/scripts[root@db01 scripts]# ./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data--user 指定mysql用户--basedir 指定mysql安装目录--datadir 指定mysql数据目录11.修改MySQL启动脚本及启动程序
[root@db01 scripts]# sed -i 's#/usr/local#/application#g' /etc/init.d/mysql /application/mysql/bin/mysqld_safe12.启动MySQL
[root@db01 scripts]# /etc/init.d/mysqld start13.添加环境变量
[root@db01 scripts]# echo 'export PATH="/application/mysql/bin:$PATH"' > /etc/profile.d/mysql.sh14.加载环境变量
[root@db01 scripts]# source /etc/profile15.添加systemd启动
[root@db01 scripts]# vim /etc/systemd/system/mysqld.service
[Unit]Description=MySQL ServerDocumentation=man:mysqld(8)Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.htmlAfter=network.targetAfter=syslog.target[Install]WantedBy=multi-user.target[Service]User=mysqlGroup=mysqlExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnfLimitNOFILE = 5000 MySQL查看报错:[root@db01 scripts]# tail -100 /application/mysql/data/db01.err 连接MySQL:[root@db01 scripts]# mysql查看库:
mysql> show databases;