CentOS7使用rpm安装mysql5.7
第一步、前往mysql官网下载所需的版本
Mysql5.7的rpm包下载地址为https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
下载完成后就上传的CentOS系统上。
第二步、解压安装
[root@youxi2 ~]# mkdir Mysql //创建一个专门的Mysql目录
[root@youxi2 ~]# tar xf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar -C Mysql/ //将解压的文件放到Mysql目录下
[root@youxi2 ~]# yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel net-tools //安装依赖包
由于CentOS7开始自带的数据库是mariadb,所以需要卸载系统中的mariadb组件,才能安装mysql的组件
[root@youxi2 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@youxi2 ~]# yum -y remove mariadb-libs
现在开始安装mysql,由于依赖关系,所以顺序是固定的。
[root@youxi2 ~]# rpm -ivh Mysql/mysql-community-common-5.7.16-1.el7.x86_64.rpm
警告:Mysql/mysql-community-common-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-common-5.7.16-1.e################################# [100%]
[root@youxi2 ~]# rpm -ivh Mysql/mysql-community-libs-5.7.16-1.el7.x86_64.rpm
警告:Mysql/mysql-community-libs-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-5.7.16-1.el7################################# [100%]
[root@youxi2 ~]# rpm -ivh Mysql/mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
警告:Mysql/mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-compat-5.7.1################################# [100%]
[root@youxi2 ~]# rpm -ivh Mysql/mysql-community-client-5.7.16-1.el7.x86_64.rpm
警告:Mysql/mysql-community-client-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-client-5.7.16-1.e################################# [100%]
[root@youxi2 ~]# rpm -ivh Mysql/mysql-community-server-5.7.16-1.el7.x86_64.rpm //之后安装就成功了
警告:Mysql/mysql-community-server-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-5.7.16-1.e################################# [100%]
第三步、启动mysql并设置开机自启
[root@youxi2 ~]# systemctl start mysqld
[root@youxi2 ~]# systemctl enable mysqld
[root@youxi2 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2019-06-02 12:11:34 CST; 45s ago
Main PID: 7840 (mysqld)
CGroup: /system.slice/mysqld.service
└─7840 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 6月 02 12:11:26 youxi2 systemd[1]: Starting MySQL Server...
6月 02 12:11:34 youxi2 systemd[1]: Started MySQL Server.
第四步、获取mysql临时密码,设置mysql的root用户密码
[root@youxi2 ~]# grep "password" /var/log/mysqld.log //前往日志文件查找临时密码
2019-06-02T04:11:28.935057Z 1 [Note] A temporary password is generated for root@localhost: zS+u&ro49wbo
[root@youxi2 ~]# mysql -uroot -p"zS+u&ro49wbo"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16 Copyright (c) 2000, 2016, 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> alter user 'root'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by 'root1234';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by 'root1234ABC';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by 'root1234ABCD!@#$';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
修改密码出来使用“alter user 'root'@'localhost' identified by 'root1234ABCD!@#$';”,也可以使用“set password for root@localhost=password('root1234ABCD!@#$');”
第五步、测试
由于有特殊符号,必须用引号包裹密码
[root@youxi2 ~]# mysql -u root -p'root1234ABCD!@#$'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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>
扩展:如果想要设置简单密码概如何操作?
有两种方法,一种在mysql里使用命令修改,一种直接修改配置文件。
在mysql里使用命令修改的办法:
[root@youxi2 ~]# mysql -u root -p'root1234ABCD!@#$'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> select @@validate_password_policy; //这个参数是密码复杂程度
+----------------------------+
| @@validate_password_policy |
+----------------------------+
| MEDIUM |
+----------------------------+
1 row in set (0.02 sec) mysql> select @@validate_password_length; //这个参数是密码长度
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 8 |
+----------------------------+
1 row in set (0.00 sec)
mysql> set global validate_password_policy=0; //global全局的
Query OK, 0 rows affected (0.02 sec) mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec) mysql> set password for root@localhost=password('123');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> set password for root@localhost = password('1234'); //设置密码
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; //刷新
Query OK, 0 rows affected (0.00 sec) mysql> exit //退出
Bye
[root@youxi2 ~]# mysql -uroot -p1234
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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>
说明:1.validate_password_policy复杂度级别:0表示密码达到长度即可;1表示密码需达到长度,还需有数字、大小写字母(可以单一可以混合)以及特殊字符;2表示密码需达到长度,还需数字、大小写字母(可以单一可以混合)以及特殊字符字典文件。MEDIUM是中等,也就是1。
2.validate_password_length其实是一个动态的值,它的最小值等于validate_password_number_count+validate_password_special_char_count+(2*validate_password_mixed_case_count),而这三个参数分别对应密码中数字、特殊字符、大小写字母的最小数量。我操作时设置了validate_password_length=1,实际再次读取validate_password_length的值是4。
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 4 |
+----------------------------+
1 row in set (0.00 sec)
直接修改配置文件的办法:
[root@youxi2 ~]# vim /etc/my.cnf
validate-password=OFF //在[mysqld]模块内添加,将validate_password插件关闭
[root@youxi2 ~]# systemctl restart mysqld //重启mysqld服务
[root@youxi2 ~]# mysql -uroot -p1234
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> set password for root@localhost=password('1'); //validate_password插件关闭后密码长度只需大于等于1即可,复杂度没有要求
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; //刷新
Query OK, 0 rows affected (0.00 sec) mysql> exit //退出
Bye
[root@youxi2 ~]# mysql -uroot -p1
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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是自带validate_password插件,关闭后对密码没有复杂度要求,只需密码长度大于等于1。
建议:/etc/my.cnf中将默认字符集设置为utf8,即添加一行character_set_server=utf8,然后重启mysqld
参考:https://blog.csdn.net/xyajia/article/details/77096974
CentOS7使用rpm安装mysql5.7的更多相关文章
- centos7用rpm安装mysql5.7【初始用yum安装发现下载非常慢,就考虑本地用迅雷下载rpm方式安装】
1.下载 4个rpm包 mysql-community-client-5.7.26-1.el7.x86_64.rpmmysql-community-common-5.7.26-1.el7.x86_64 ...
- CentOS7使用yum安装mysql5.7
提前说一下,网速不好不要用yum安装,等得时间太长. 第一步.获取yum源 [root@youxi1 ~]# rpm -ivh https://repo.mysql.com/yum/mysql-5.7 ...
- 阿里云Centos7使用yum安装MySQL5.6的正确姿势
阿里云Centos7使用yum安装MySQL5.6 阿里云Centos7使用yum安装MySQL5.6 前言:由于某些不可抗力,我要在自己的阿里云服务器上搭建hadoop+hive+mysql+tom ...
- linux 环境RPM 安装MYSQL5.6
linux 环境RPM 安装MYSQL5.6 系统环境 CentOS7.2 1.关闭selinux 服务[SELinux是一种基于域-类型 模型(domain-type)的强制访问控制(MAC)安全系 ...
- CentOS7 通过YUM安装MySQL5.7 linux
CentOS7 通过YUM安装MySQL5.7 1.进入到要存放安装包的位置 cd /home/lnmp 2.查看系统中是否已安装 MySQL 服务,以下提供两种方式: rpm -qa | grep ...
- Linux(CentOS7)下二进制安装MySQL5.7.26
记录一下自己在 CentOS7 下二进制安装 MySQL5.7.26 的过程,之前使用 Linux(CentOS7)下rpm安装MySQL8.0.16 之后发现 rpm 方式安装不利于维护,也不利于单 ...
- RPM安装MySQL5.7并更改数据目录
RPM安装MySQL5.7并更改数据目录 文末附MySQL完整配置文件 官网地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads 注意 ...
- centos7.6自动化安装mysql5.5
一.目的 简化安装mysql的安装过程,局限很大,仅支持centos7.6上安装mysql5.5.60,如果想在其他版本的操作系统安装mysql,请自行修改有关变量. 如果想了解mysql安装的具体过 ...
- RPM安装MYSQL5.7
RPM安装MYSQL5.7 1:YUM安装依赖库 yum install perl libaio numactl 2:下载安装需要的RPM包 https://dev.mysql.com/get/Dow ...
随机推荐
- python之列表、元组
Day 2-Morning 创建列表 创建列表和创建普通变量一样,用中括号括起一堆数据即可(这里的数据可以是整型.字符串.浮点型...甚至可以包含另一个列表),数据间用逗号隔开. eg:number= ...
- 15_sqoop数据导出
1.Sqoop的数据导出 将数据从HDFS导出到RDBMS数据库,导出前,目标表必须存在于目标数据库中 默认操作是将文件中的数据使用INSERT语句插入到表中 更新模式下,是生成UPDATE语句更新表 ...
- openpose-opencv 的body数据多人体姿态估计
介绍 opencv除了支持常用的物体检测模型和分类模型之外,还支持openpose模型,同样是线下训练和线上调用.这里不做特别多的介绍,先把源代码和数据放出来- 实验模型获取地址:https://gi ...
- httprunner---->最最基础小白笔记
1.安装httprunner pip install httprunner 2.cmd 执行hrun --startproject Api_api 出现了: 3.Fiddler抓包后 ...
- re模块中的非贪婪匹配
python的re模块中有贪婪匹配和非贪婪匹配之分,当使用*时会匹配零个或多个,使用+时会匹配一个或多个.当使用?在前边特殊符号前时会进行非贪婪匹配,匹配零个或者一个,今天主要讨论非贪婪匹配中存在的坑 ...
- 尤娜博客系统 Una
站长资讯平台:Una [‘尤娜’] 只是一个项目代号,没有特殊含义.尤娜是站在巨人的肩膀上开发完成的博客系统,旨在为程序员提供一个极简的内容创作管理平台,尤娜100%开放源代码,如果您对她感兴趣,Fo ...
- 谷歌浏览器不兼容的一些Js
这篇博文主要记录本人在实际应用中碰到的谷歌浏览器与一些Js不兼容的问题,随着时间的推移,这篇博文的内容可能越来越多,也可能一点也没有(我想那时候谷歌肯定是相当牛逼的). 1.谷歌浏览器不兼容docum ...
- final详解
final的含义? final:java中的关键字,意为“终态的”或者“无法改变的”.可用来修饰类.变量.方法. 变量(成员变量.静态变量.局部变量) 注意: 1.final变量即为常量,通常常量名大 ...
- CF70E Information Reform
题意:给你一棵树,要选择若干节点,若一个点i没有选择,则有\(d(dis(i,j))\)的代价,其中j被选择.选择一个点代价为k,求最小代价. 首先,考虑这样一个问题: 如果距离a的最近被选点为i,距 ...
- 洛谷P1903 [国家集训队]数颜色 / 维护队列 ( 带 修 )
题意:有两种操作: 1. Q L R代表询问你从第L支画笔到第R支画笔中共有几种不同颜色的画笔. 2. R P Col 把第P支画笔替换为颜色Col. 对每个1操作 输出答案: 带修莫队 模板题 (加 ...