centos7下安装mysql5.7数据库

15 篇文章 0 订阅

转:https://blog.csdn.net/WYA1993/article/details/88890883

1.下载MySQL安装
[root@localhost data]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
如果提示wget命令不存在,先执行:yum -y install wget
下载完成后多了一个mysql57-xxx的文件,这个就是mysql安装源

2.安装mysql安装源

[root@localhost data]# yum -y localinstall mysql57-community-release-el7-11.noarch.rpm 
3.在线安装MySQL

[root@localhost data]# yum -y install mysql-community-server
下载的东西有点多,需要等待一会

4.启动MySQL服务

[root@localhost data]# systemctl start mysqld
5.设置开机启动

[root@localhost data]# systemctl enable mysqld
[root@localhost data]# systemctl daemon-reload
6.修改root登录密码

mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。

[root@localhost data]# vim /var/log/mysqld.log


复制此密码,使用此密码登录root

[root@localhost data]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25
 
Copyright (c) 2000, 2019, 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> 
修改密码, mysql5.7默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test2016@';
Query OK, 0 rows affected (0.01 sec)


 
7.设置允许远程登录

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

mysql> exit
Bye
8.,防火墙开放3306端口

[root@localhost data]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
 
success
 
[root@localhost data]# firewall-cmd --reload
 
success
 
[root@localhost data]# 
9.配置mysql默认编码为utf-8

修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置

character_set_server=utf8

init_connect='SET NAMES utf8'

:wq!保存退出

10.重启MySQL

[root@localhost data]# systemctl restart mysqld
11.登录root用户查看编码

12.测试远程连接

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值