CentOS 7 yum安装MySQL 5.7

1 wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
2 rpm -ivh mysql80-community-release-el7-3.noarch.rpm
3 vi /etc/yum.repos.d/mysql-community.repo
4 For example, to install MySQL 5.7, make sure you have enabled=0 for the above subrepository entry for MySQL 8.0, and have enabled=1 for the entry for the 5.7 series:

Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

5 yum install mysql-community-server
6 systemctl start mysqld.service
7 systemctl enable mysqld.service
8 grep ‘temporary password’ /var/log/mysqld.log
9 mysql -uroot -p
10 alter user ‘root’@‘localhost’IDENTIFIED BY ‘YQXpxx@2017’;
11 Securing the MySQL Installation (for MySQL 5.6 only)
mysql_secure_installation
12 grant all privileges on . to ‘root’@’%’ identified by ‘123456’ with grant option;
flush privileges;

show variables like ‘%character%’;
vi /etc/my.cnf
[mysqld]
character-set-server=utf8

mysql8
1:linux登录mysql
[root@localhost mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.13 MySQL Community Server - GPL

Copyright © 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

2:查看user表,修改连接级别
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user from user;
±----------±-----------------+
| host | user |
±----------±-----------------+
| localhost | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
±----------±-----------------+
4 rows in set (0.00 sec)
可以看到,root用户的host值为localhost,这代表只能本地连接,将localhost修改为%
update user set host=’%’ where user=‘root’;
3:可能你觉得到这一步就完事了,但是使用navicat连接测试时,会提示无法解析主机名相关的错误,这是mysql8的一些安全策略的问题,具体请左转google,解决办法如下
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘yourpassword’;
4:完毕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

充值内卷

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值