使用源码安装比较费时间,推荐使用二进制文件进行安装(好想也费下载的时间,不过50M带宽表示无压力)
1、下载
wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
没有wget命令使用yum install wget -y 安装
2、解压并copy
tar zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
cp mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql -r
3、进入文件夹
cd /usr/local/mysql/
4、添加系统mysql组和mysql用户
grouped mysql
useradd -r -g mysql mysql
5、修改当前目录拥有者为mysql用户
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql
6.1如果出现Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
说明确实依赖包libaio
使用yum 安装
yum install libaio-devel.x86_64 -y
6.2如果出现 FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
使用yum安装
yum-y install autoconf
7、修改当前目录拥有者为root用户
chown -R root:root ./
8、修改当前data目录拥有者为mysql用户
chown -R mysql:mysql data
9、添加软连接,这样就可以直接使用msyql
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
10、添加开机启动
cp support-files/mysql.server /etc/init.d/mysql
11、启动mysql服务
service mysql start
12、测试
mysql -uroot -p
成功
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.31 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 its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>