yum install perl perl-devel
cd /usr/local/src
wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
tar zxvf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql
useradd -s /sbin/nologin mysql
创建存放数据的目录:
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql/
执行:
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
配置文件:
cp support-files/my-default.conf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld ,在配置里找到 basedir datadir 进行设置(如果mysqld文件中没有找到就在my.cnf中找)
basedir=/usr/local/mysql datadir=/data/mysql
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
查看mysql是否启动的命令
ps aux |grep mysqld
2、连接mysql
mysql -uroot -p(解决:-bash:mysql:command not found;ln -s /usr/local/mysql/bin/mysql /usr/bin 做个链接即可)