首页 > 代码库 > CentOS 6.7安装Mysql 5.7

CentOS 6.7安装Mysql 5.7

Step1: 检测系统是否自带安装mysql

# yum list installed | grep mysql

Step2: 删除系统自带的mysql及其依赖
命令:

# yum -y remove mysql-libs.x86_64

Step3: 下载mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz

Step4:解压mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz,并更名为mysql,再放到/usr/local目录下

 

Step5:

添加mysql用户和组,然后安装mysql并启动,初始密码由/root/.mysql_secret保存,使用的命令如下:

groupadd mysql

useradd mysql -g mysql

cd /usr/local/mysql/bin

yum install libaio

./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

cd /usr/local/mysql/support-files

./mysql.server start

Stop6:

使用初始密码登录mysql,并修改密码,同时设置root可以远程连接

命令如下:

cat /root/.mysql_secret

cd /usr/local/mysql/bin

./mysql -u root -p

set password =password(‘新密码‘);

GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "1新密码";

flush privileges;

可能远程连接不了,尝试关闭防火墙,命令如下:

service iptables stop

setenforce 0

Step 7:

sr将mysql设置为开机自启动,并添加软连接

命令如下:

cd /usr/local/mysql/support-files/

cp mysql.server /etc/init.d

cd /etc/init.d

mv mysql.server mysqld

cd /usr/bin

ln -s /usr/local/mysql/bin/mysql mysql 

 

参考:

http://jingyan.baidu.com/article/e5c39bf5aa60f639d7603316.html

http://wenku.baidu.com/link?url=pyNWlzvD9_E-PSupm34oC0DwsZ_zXSRLIbvaGcioruAuEAjqVdbqqKW912BYpwCxpGIP9eiWsxvX9CQtZsWXVSu3ZyWnnzFFRvmBAzjlJvG

CentOS 6.7安装Mysql 5.7