1、下载对应安装包 https://dev.mysql.com/downloads/mysql/
2、卸载旧版本mysql
列出旧版本MySql的组件列表 rpm -qa | grep mysql
移除相关组件 rpm -e --nodeps {-file-name}
3、解压tar -zxvf mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar 报错
gzip: stdin: not in gzip format
3 tar: Child returned status 1
4 tar: Error is not recoverable: exiting now
压缩包没有用gzip格式压缩,所以不用加z参数 命令改为 tar -xvf mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar
4、按照依赖关系依次安装rpm包 依赖关系依次为common→libs→client→server
# rpm -ivh mysql-community-common-5.7.25-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm
# rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm
*在安装 mysql-community-libs-5.7.25-1.el7.x86_64.rpm 时有可能会报错:mysql依赖错误
warning: mysql-community-libs-5.7.25-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.25-1.el7.x86_64
mariadb-libs is obsoleted by mysql-community-libs-5.7.25-1.el7.x86_64
解决:清除yum里所有mysql依赖包
# rpm -qa|grep mysql
# yum remove mysql-libs
5、启动mysql
# systemctl start mysqld
6、登录mysql
获得安装时默认密码
# cat /var/log/mysqld.log | grep "temporary password"
# mysql -uroot -p
**登录成功操作会报错需要修改密码
mysql > set password for root@localhost=password('你的密码);
授权远程访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
执行某段sql脚本报错
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
解决