首先从官网下载这4个安装包:
下载地址:http://dev.mysql.com/downloads/mysql/#downloads
下载安装包:
- mysql-community-libs-5.7.11-1.el6.x86_64.rpm
- mysql-community-common-5.7.11-1.el6.x86_64.rpm
- mysql-community-client-5.7.11-1.el6.x86_64.rpm
- mysql-community-server-5.7.11-1.el6.x86_64.rpm
rpm -qa|grep mysql
如果有, 就卸载掉
rpm -e mysql-libs-xxxx.x86_64 --nodeps
然后就可以安装了
安装顺序如上面序号
rpm -ivh mysql-community-common-5.7.9-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm
安装完之后, 启动服务
service mysqld start
mysql5.7 默认密码不是空的, 与以前版本不同, 密码在 /var/log/mysqld.logs 的日志中:
[Note] A temporary password is generated for root@localhost: O87k7yABUw:s
类似于此, 密码是随机生成的
然后登录mysql
mysql -uroot -pO87k7yABUw:s
进去之后, 发现使用任何命令都会提示:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
意思应该是让你改个密码
那我们就改个密码:
alter user 'root'@'localhost' identified by 'NiDaYeDe@12345';
flush privileges;
注意, 密码需要有大小写与特殊符号和数字, 增加了安全性吧, 是可以通过配置的, 但安全性高点也好
接着就是看下数据库编码:
show variables like '%char%';
发现 character_set_database与character_set_server 使用的是西欧编码
更改下编码
vim /etc/my.cnf
在mysqld 中增加
character_set_server=utf8
init_connect='SET NAMES utf8'
保存, 重启mysql
service mysqld restart
就OK了