centos7安装mysql5.7

1.去mysql官网获取mysql的下载链接

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


centos7安装mysql5.7
 

2.下载mysql rpm包

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

3.rpm安装

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

4.rpm安装完成之后yum安装

yum install mysql57-community-release-el7-11.noarch.rpm

5.安装完成之后查看初始密码

grep temporary password /var/log/mysqld.log

6.测试登录

mysql -uroot -p

7.如果登录之后无法做任何操作或者登录报1045错误代码,则尝试修改密码并重新登录

   $ sudo systemctl stop mysqld.service

     $ sudo systemctl set-environment MYSQLD_OPTS="--user=mysql --skip-grant-tables --skip-networking"
     $ sudo systemctl start mysqld.service    
     $ mysql -u root mysql
 
     mysql > UPDATE mysql.user SET authentication_string=PASSWORD("abcdef")  WHERE user='root' and host='localhost';
     mysql > flush privileges;
     mysql > quit
 
     $ sudo systemctl unset-environment MYSQLD_OPTS
     $ sudo systemctl restart mysqld.service

 mysql 开启远程连接

1. 登录数据库

mysql -uroot -p

 2. 开启远程连接

    root 用户名
    % 所有人都可以访问
    password 密码

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

 3. 重启mysql

service mysqld restart

 执行完以上步骤还是不能远程连接mysql的话,尝试开放防火墙的3306端口或者关闭防火墙

相关推荐