centos7安装mysql5.7

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hqzxsc2006/article/details/88115217
  1. 卸载MariaDB

先查看一下系统上的mariadb

#rpm -qa | grep mariadb

mariadb-libs-5.5.56-2.el7.x86_64

然后卸载

#rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

rpm -ivh 包名 安装软件包
2. 官网下载对应版本https://dev.mysql.com/downloads/mysql/
在这里插入图片描述
3.解压 tar xf mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar
4. 安装rpm -ivh mysql-community-common-5.7.25-1.el7.x86_64.rpm
5. 安装rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm
6. 安装rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm
7. 安装rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm
8.启动mysql service mysqld start
9.修改my.cnf, vim /etc/my.cnf 加入以下内容

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
validate_password=off
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci

10.重启mysql service mysqld restart
11.获取root密码 cat /var/log/mysqld.log|grep “temporary password”
12.登录修改root密码 mysql -uroot -p
13.设置新密码

mysql> set password=password('新密码');
mysql> flush privileges; #刷新

14.添加远程访问权限

mysql> use mysql
mysql> update user set host='%' where user='root';
mysql> select host,user from user;
mysql> flush privileges;

15.重启mysql service mysqld restart

展开阅读全文

没有更多推荐了,返回首页