centos7 rpm安装或者升级mysql5.7

升级mysql:
在安裝mysql之前先确认先前是否安装了mysql,如有就删除:

- --To list Old MySql
yum list installed | grep -i mysql
--卸载旧版本的mysql(To remove Old MySql)
yum remove mysql mysql-*
--移除命令执行后,可再看看是否有残余的mysql,输入命令:
yum list installed | grep mysql
--如果有,可输入命令删除:
yum remove mysql-libs

1.从官网https://dev.mysql.com/downloads/file/?id=470281 找到下载rpm链接:

https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

centos7 rpm安装或者升级mysql5.7_第1张图片
2.
先创建mysqlDownload目录:mkdir mysqlDownload

[sunwei@localhost mysqlDownload]$ wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

3.

[sunwei@localhost mysqlDownload]$ sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm

4.

[sunwei@localhost mysqlDownload]$ sudo yum install mysql-community-server

到此步安装完成
mysql –version #查看mysql版本信息


查看临时密码:vi /var/log/mysqld.log
centos7 rpm安装或者升级mysql5.7_第2张图片
登录mysql之后修改临时密码:
修改之前先:

     mysql> set global validate_password_policy=0;
     Query OK, 0 rows affected (0.00 sec)
     mysql> set global validate_password_length=1;
     Query OK, 0 rows affected (0.00 sec)

接触mysql5.7 对密码的限制
修改密码:

mysql> alter user 'root'@'localhost' identified by 'pass';
Query OK, 0 rows affected (0.00 sec)

添加远程登录用户:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'pass' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

如果是升级mysql版本:
出现报错:
ERROR 1682 (HY000): Native table ‘performance_schema’.’session_variables’ has the wrong structure

则需要执行以下:
mysql_upgrade -u root -p –force
然后需要重启mysql

你可能感兴趣的:(Mysql)