1.先下载5.6.tar.gz 包
https://downloads.mysql.com/archives/community/
cd /usr/local
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.6.51-linux-glibc2.12-x86_64.tar.gz
2.安装依赖
sudo apt-get install libaio1 # install library
yum search libaio # search for info
yum install libaio # install library
3.解压缩到/usr/local
$> sudo groupadd mysql
$> sudo useradd -r -g mysql -s /bin/false mysql
$> sudo cd /usr/local
$> sudo tar zxvf /path/to/mysql-VERSION-OS.tar.gz
$> sudo ln -s full-path-to-mysql-VERSION-OS mysql
4.将/usr/local/mysql/bin添加到环境变量
1.编写*.sh文件
sudo vim /etc/profile.d/add_mysql_path.sh
2.内容如下:
export PATH=$PATH:/usr/local/mysql/bin
3.source /etc/profile
4.echo $PATH 查看/usr/local/mysql/bin是否存在
4.添加到init.d
$> cd /usr/local/mysql
$> sudo scripts/mysql_install_db --user=mysql
cp support-files/mysql.server /etc/init.d/
5.添加开机自启动
ubuntu18.04
sudo update-rc.d mysql.server defaults
查看/etc/rc2-6*.d目录是否存在S01mysql.server 存在就添加成功
centos7
chkconfig --add mysql.server
chkconfig --list mysql.server
6.测试
sudo reboot
ps -ef|grep mysqld 是否存在进程
root 831 1 0 08:55 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/joker.pid
mysql 954 831 0 08:55 ? 00:00:05 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=joker.err --pid-file=/usr/local/mysql/data/joker.pid