mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar下载:
链接:https://pan.baidu.com/s/1FLdXXFNI1kmUIdpsjtYTxQ
提取码:g3mt (链接不可用请直接留言即可)
1.卸载以前安装过的mysql文件
rpm -qa | grep -i mysql
rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
2.上传并解压文件
tar xvf mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar
3.安装对应的包(必须按照顺序)
rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.25-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.25-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.25-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.25-1.el6.x86_64.rpm
4.启动mysql
service mysqld start(第一次可能会失败,再试一次即可)
5.获取mysql初始化密码
grep 'temporary password' /var/log/mysqld.log
6.修改mysql密码
mysqladmin -u root -p password
7.数据库查看编码
mysql>SHOW VARIABLES LIKE '%char%';
发现字符编码有latin1
8.修改/etc/my.cnf (默认在这个目录)
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
9.重启mysql
service mysqld restart
修改成功!
最后,赋予任何主机访问数据的权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> Flush privileges;
若有不正之处请多多谅解,并欢迎批评指正。