【centos7 + MySQL5.7 安装】centos7 安装MySQL5.7

【centos7 + MySQL5.7 安装】centos7 安装MySQL5.7说明:我们安装MySQL位置在/usr/local下第一步、下载MySQL安装包:[root@localhostlocal]#wgethttps://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm安装mysql安装源:[root@localhostlocal]#yum-ylocali…

大家好,又见面了,我是你们的朋友全栈君。

说明:我们安装MySQL位置在 /usr/local 下

第一步、下载MySQL 安装包:

[root@localhost local]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装mysql 安装源:

[root@localhost local]# yum -y localinstall mysql57-community-release-el7-11.noarch.rpm 

第二步,在线安装MySQL

[root@localhost local]# yum -y install mysql-community-server

等待时间比较久:
在这里插入图片描述

第三步、启动mysql 服务

[root@localhost local]# systemctl start mysqld

第四步,设置开机启动

[root@localhost local]# systemctl enable mysqld
 
[root@localhost local]# systemctl daemon-reload

第五步,修改root登录密码

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

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

在这里插入图片描述
记住初始密码:
修改root 密码

[root@localhost local]# mysql -u root -p

在这里插入图片描述

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'daasan7ujm^YHN';
Query OK, 0 rows affected (0.00 sec)
# 设置远程登录
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'daasan7ujm^YHN' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

第六步,退出

mysql> exit

第七步,防火墙开放3306端口

[root@localhost sysconfig]# cd /etc/sysconfig/
[root@localhost sysconfig]# vim iptables
#添加代码如下
-A INPUT -p tcp --dport 3306 -j ACCEPT

在这里插入图片描述
第八步,重启防火墙。

[root@localhost sysconfig]# service iptables restart

第九步,配置mysql默认编码为utf-8

[root@localhost sysconfig]# vim /etc/my.cnf

添加如下代码

character_set_server=utf8
init_connect='SET NAMES utf8'

在这里插入图片描述
:wq 保存退出

第十步,重启MySQL

[root@localhost data]# systemctl restart mysqld

第十一步, root 用户登录查看编码

[root@localhost sysconfig]# 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.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> 

最后本地连接测试:
在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/133232.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 批处理for命令的用法_批处理主要解决

    批处理for命令的用法_批处理主要解决1.前言for是批处理中最复杂,也最强大的关键字。熟练掌握for的用法,才可能理解批处理的强大之处。2.基本用法2.1.概念for是对一组文件中的每一个文件执行某个特定命令。FOR%variableIN(set)DOcommand[command-parameters]%variable,指定一个单一字母可替换的参数。(set),指定一个或一组文…

    2022年8月31日
    2
  • 伽马分布与贝塔分布转换关系_伽马分布期望推导

    伽马分布与贝塔分布转换关系_伽马分布期望推导伽马函数称为伽马函数,其中参数,伽马函数具有如下性质: ,n为自然数;或写作余元公式:对于,有与贝塔函数的关系: 对于;伽马函数是严格凹函数。 x足够大时,可以用Stirling公式来计算Gamma函数值:伽马分布背景:若一个元器件能抵挡一些外来冲击,但遇到第k次冲击即告失效,则第k次冲击来到的时间X(寿…

    2025年5月26日
    0
  • Django接口_小米电视spdif接口

    Django接口_小米电视spdif接口前言在RESTful规范中,有关版本的问题,用restful规范做开放接口的时候,用户请求API,系统返回数据。但是难免在系统发展的过程中,不可避免的需要添加新的资源,或者修改现有资源。因此,改动升

    2022年7月30日
    7
  • C# excel转换Json

    C# excel转换Json//如果要支持xlsx格式表格,请在本机电脑安装这个//http://download.microsoft.com/download/7/0/3/703ffbcb-dc0c-4e19-b0da-1463960fdcdb/AccessDatabaseEngine.exe参考案例:https://www.cnblogs.com/fengxiang/p/3551621.html使用的时候记得…

    2022年6月11日
    51
  • 利用linux BT5来破解无线 破解无线[通俗易懂]

    利用linux BT5来破解无线 破解无线

    2022年1月21日
    101
  • 做一个电商网站需要多少钱

    做一个电商网站需要多少钱做一个电商网站详细成本一、域名费用:有些的顶级域名非常贵,但如果需要搭建一个好的商城,那么域名也要最好的,因此,域名的成本非常高。

    2022年9月1日
    1

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号