Centos7 安装和配置MySQL5.7
程序员文章站
2022-05-08 10:58:33
...
-
[aaa@qq.com ~]# cd /home/data/
-
[aaa@qq.com data]# ls
-
get-docker.sh nginx-1.10.1 nginx-1.10.1.tar.gz redis-5.0.3 redis-5.0.3.tar.gz server-jre-8u131-linux-x64.tar.gz zookeeper-3.4.10.tar.gz
-
[aaa@qq.com data]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
如果提示wget命令不存在,先执行
yum -y install wget
下载完成后
多了一个mysql57-xxx的文件,这个就是mysql安装源
安装mysql安装源
[aaa@qq.com data]# yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
第二步,在线安装MySQL
[aaa@qq.com data]# yum -y install mysql-community-server
下载的东西有点多,需要等待一会
第三步,启动MySQL服务
[aaa@qq.com data]# systemctl start mysqld
第四步,设置开机启动
-
[aaa@qq.com data]# systemctl enable mysqld
-
-
[aaa@qq.com data]# systemctl daemon-reload
第五步,修改root登录密码
mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。
[aaa@qq.com data]# vim /var/log/mysqld.log
复制此密码,使用此密码登录root
-
[aaa@qq.com 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 'aaa@qq.com';
-
Query OK, 0 rows affected (0.01 sec)
-
第六步,设置允许远程登录
-
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'aaa@qq.com' WITH GRANT OPTION;
-
Query OK, 0 rows affected, 1 warning (0.00 sec)
第七步,退出
-
mysql> exit
-
Bye
第八步,防火墙开放3306端口
-
[aaa@qq.com data]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
-
-
success
-
-
[aaa@qq.com data]# firewall-cmd --reload
-
-
success
-
-
[aaa@qq.com data]#
第九步,配置mysql默认编码为utf-8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置
character_set_server=utf8
init_connect='SET NAMES utf8'
:wq!保存退出
第十步,重启MySQL
[aaa@qq.com data]# systemctl restart mysqld
第十一步,登录root用户查看编码
第十二步,测试远程连接
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">点赞</span>
<span class="count">5</span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打赏开始-->
<!--打赏结束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章举报</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/WYA1993">
<img src="https://profile.csdnimg.cn/6/F/2/3_wya1993" class="avatar_pic" username="WYA1993">
<img src="https://g.csdnimg.cn/static/user-reg-year/1x/4.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.csdn.net/WYA1993" data-report-click="{"mod":"popu_379"}" target="_blank">myCat、</a></span>
</div>
<div class="text"><span>发布了141 篇原创文章</span> · <span>获赞 88</span> · <span>访问量 17万+</span></div>
</div>
<div class="right-message">
<a href="https://im.csdn.net/im/main.html?userName=WYA1993" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379"}">关注</a>
</div>
</div>
</div>
</article>
上一篇: spring cloud config git 远程仓库的坑
下一篇: Redis数据库