CentOS7.5二进制安装MySQL-5.6.40

mysql-5.6.40二进制包下载地址 MD5值 10f61e60f8c42b6635e5c1f423bce8be

https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz

mysql-5.6.41二进制包下载地址 MD5值 b0ac6851908b5c17b6a283d10709fcfd

https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz

mysql-5.6.42二进制包下载地址 MD5值 fc8c6df660ba42b280c3b1d59bd8ee27

https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz


1.下载MySQL-5.6.40二进制包

wget https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz

2.解压缩mysql二进制包到/usr/local

tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -C /usr/local

3.修改名称、做软连接

mv /usr/local/mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql-5.6.40
ln -s /usr/local/mysql-5.6.40 /usr/local/mysql

4.创建mysql用户

#创建mysql用户
useradd mysql -s /bin/nologin -M

5.拷贝主配置文件

#备份/etc/my.cnf
mv /etc/my.cnf /etc/my.cnf.old

#拷贝主配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

6.拷贝启动脚本

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

7.相关目录、文件授权

chown -R mysql.mysql /usr/local/mysql*
chown mysql.mysql /etc/my.cnf

8.初始化mysql

#初始化前安装依赖包
yum -y install autoconf

#初始化mysql
cd /usr/local/mysql/scripts && ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

--user        #指定mysql用户
--basedir        #指定mysql安装目录
--datadir        #指定mysql数据目录

9.添加mysql命令环境变量

#导出mysql命令环境变量
echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh

#使配置生效
source /etc/profile

10.配置systemd管理mysql

cat > /etc/systemd/system/mysqld.service <<'EOF'
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF

11.启动mysql、检查启动

#重新加载systemd系统服务
systemctl daemon-reload

#启动mysql
systemctl start mysqld && systemctl enable mysqld

#查看mysql端口
$ netstat -ntpl  | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      31349/mysqld

12.进入mysql并设置密码

#进入mysql
mysql

#设置mysql密码
mysql> set password='123';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

到此,mysql5.6.40二进制安装完成!!!

泡泡吐肥皂o © gitbook.pptfz.top 2021 all right reserved,powered by Gitbook文件修订时间: 秃笔南波湾!!!

results matching ""

    No results matching ""