1、环境
CentOS-6.4
mysql 5.7
2、下载mysql http://dev.mysql.com/downloads/mysql/(个人认为centos6即下载el6版本,centos7下载el7版本)
mysql-community-client-5.7.12-1.el6.i686.rpm
mysql-community-common-5.7.12-1.el6.i686.rpm
mysql-community-libs-5.7.12-1.el6.i686.rpm
mysql-community-server-5.7.12-1.el6.i686.rpm
3、安装
3.1、删除已安装mysql 包
# rpm -qa|grep mysql
mysql-libs-5.1.66-2.el6_3.i686
# rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.i686
3.2 使用rpm 命令安装(注意安装顺序)
安装mysql
#rpm -hiv mysql-community-common-5.7.12-1.el6.i686.rpm
#rpm -hiv mysql-community-libs-5.7.12-1.el6.i686.rpm
#rpm -hiv mysql-community-client-5.7.12-1.el6.i686.rpm
#rpm -hiv mysql-community-server-5.7.12-1.el6.i686.rpm
4、启动mysql
# service mysqld start
5、mysql5.7 开始有默认的密码
# cat /var/log/mysqld.log|grep 'temporary password'
2016-06-21T20:44:15.278096Z 1 [Note] A temporary password is generated for root@localhost:=g0tde)VFWqE
初始密码为:=g0tde)VFWqE
6、登录
# mysql -uroot -p
输入密码
登录后修改默认密码(mysql密码有安全要求,要求有大小写特殊字符):
mysql> SET PASSWORD = PASSWORD('Abc123!@#');
也可更改默认密码强度
set global validate_password_policy=0;
7、授权远程连接
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Abc123!@#' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
说明:如果远程连接不上,关闭防火墙。
8、设置自启动
# chkconfig --add mysqld
# chkconfig --level 2345 mysqld