vm12下Centos6安装mysql5.7
一、下载mysql的rpm tar文件
文件名称:mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar
官方地址:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar
二、卸载原有的mysql
请查看tony~tian的博客:https://yq.aliyun.com/articles/58287
三、安装mysql
1、解压
- # 将mysql-5.7.-.el6.x86_64.rpm-bundle.tar压缩包解压到/usr/wangzf/mysqlrpm/下
- [root@localhost downloads]# tar -xvf mysql-5.7.-.el6.x86_64.rpm-bundle.tar -C ../mysqlrpm/
- mysql-community-libs-compat-5.7.-.el6.x86_64.rpm
- mysql-community-test-5.7.-.el6.x86_64.rpm
- mysql-community-libs-5.7.-.el6.x86_64.rpm
- mysql-community-common-5.7.-.el6.x86_64.rpm
- mysql-community-embedded-5.7.-.el6.x86_64.rpm
- mysql-community-embedded-devel-5.7.-.el6.x86_64.rpm
- mysql-community-client-5.7.-.el6.x86_64.rpm
- mysql-community-devel-5.7.-.el6.x86_64.rpm
- mysql-community-server-5.7.-.el6.x86_64.rpm
- # 查看解压后的rpm软件包
- [root@localhost downloads]# cd ../mysqlrpm/
- [root@localhost mysqlrpm]# ll
- total
- -rw-r--r--. Mar : mysql-community-client-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-common-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-devel-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-embedded-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-embedded-devel-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-libs-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-libs-compat-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-server-5.7.-.el6.x86_64.rpm
- -rw-r--r--. Mar : mysql-community-test-5.7.-.el6.x86_64.rpm
2、安装mysql
- # 想要安装mysqlclient和mysqlserver,需要先安装common和libs
- [root@localhost mysqlrpm]# rpm -ivh mysql-community-common-5.7.-.el6.x86_64.rpm
- Preparing... ########################################### [%]
- :mysql-community-common ########################################### [%]
- [root@localhost mysqlrpm]# rpm -ivh mysql-community-libs-5.7.-.el6.x86_64.rpm
- Preparing... ########################################### [%]
- :mysql-community-libs ########################################### [%]
- [root@localhost mysqlrpm]# rpm -ivh mysql-community-client-5.7.-.el6.x86_64.rpm
- Preparing... ########################################### [%]
- :mysql-community-client ########################################### [%]
- [root@localhost mysqlrpm]# rpm -ivh mysql-community-server-5.7.-.el6.x86_64.rpm
- Preparing... ########################################### [%]
- :mysql-community-server ########################################### [%]
- # 查看已安装的与mysql相关的软件
- [root@localhost mysqlrpm]# rpm -qa|grep -i mysql
- mysql-community-common-5.7.-.el6.x86_64
- mysql-community-client-5.7.-.el6.x86_64
- mysql-community-libs-5.7.-.el6.x86_64
- mysql-community-server-5.7.-.el6.x86_64
安装异常处理:
- # 如果出现以下错误,请先安装perl、libnuma
- [root@slave01 mysqlrpm]# rpm -ivh mysql-community-server-5.7.-.el6.x86_64.rpm
- warning: mysql-community-server-5.7.-.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
- error: Failed dependencies:
- /usr/bin/perl is needed by mysql-community-server-5.7.-.el6.x86_64
- libnuma.so.()(64bit) is needed by mysql-community-server-5.7.-.el6.x86_64
- libnuma.so.(libnuma_1.)(64bit) is needed by mysql-community-server-5.7.-.el6.x86_64
- libnuma.so.(libnuma_1.)(64bit) is needed by mysql-community-server-5.7.-.el6.x86_64
- perl(File::Path) is needed by mysql-community-server-5.7.-.el6.x86_64
- perl(Getopt::Long) is needed by mysql-community-server-5.7.-.el6.x86_64
- perl(POSIX) is needed by mysql-community-server-5.7.-.el6.x86_64
- perl(strict) is needed by mysql-community-server-5.7.-.el6.x86_64
- [root@slave01 mysqlrpm]# yum install perl
- [root@slave01 mysqlrpm]# yum install libnuma*
3、启动mysql
- # 查看mysql服务的状态
- [root@localhost mysqlrpm]# service mysqld status
- mysqld is stopped
- # mysql尚未启动,使用service mysqld start启动(这里是第一次启动,会初始化一些参数)
- [root@localhost mysqlrpm]# service mysqld start
- Initializing MySQL database: [ OK ]
- Installing validate password plugin: [ OK ]
- Starting mysqld: [ OK ]
- # 停止mysql服务
- [root@localhost mysqlrpm]# service mysqld stop
- Stopping mysqld: [ OK ]
- # 启动mysql服务
- [root@localhost mysqlrpm]# service mysqld start
- Starting mysqld: [ OK ]
- # 重启mysql服务
- [root@localhost mysqlrpm]# service mysqld restart
- Stopping mysqld: [ OK ]
- Starting mysqld: [ OK ]
四、修改root密码
- # 关闭mysql服务
- [root@localhost ~]# service mysqld stop
- Stopping mysqld: [ OK ]
- # 安全模式下启动mysql,并且跳过权限表的验证
- [root@ ~]# mysqld_safe --skip-grant-tables &
- []
- [root@ ~]# --06T23::.604144Z mysqld_safe Logging to '/var/log/mysqld.log'.
- --06T23::.674987Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
- # 准备登陆
- mysql -u root -p
- # 这里随便输入密码,都可以进入mysql
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is
- Server version: 5.7. MySQL Community Server (GPL)
- Copyright (c) , , 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.
- # 更改密码(这里设置的密码是1234)
- mysql> update mysql.user set authentication_string=password('') where user='root' and Host = 'localhost';
- Query OK, row affected, warning (0.04 sec)
- Rows matched: Changed: Warnings:
- # 刷新权限
- mysql> flush privileges;
- Query OK, rows affected (0.00 sec)
- # 退出mysql
- mysql> quit
- Bye
- # 重启mysql
- [root@localhost ~]# service mysqld restart
- --06T23::.067045Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
- Stopping mysqld: [ OK ]
- Starting mysqld: [ OK ]
- []- Done mysqld_safe --skip-grant-tables
- # 以root身份登陆
- [root@localhost ~]# mysql -uroot -p
- # 输入刚才设置的密码1234,正常使用mysql
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is
- Server version: 5.7.
- Copyright (c) , , 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
1、centos开启防火墙端口3306
- # 开放3306端口
- [root@ ~]# /sbin/iptables -I INPUT -p tcp --dport -j ACCEPT
- # 保存
- [root@ ~]# /etc/rc.d/init.d/iptables save
- iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
- # 查看防火墙的状态
- [root@ ~]# /etc/init.d/iptables status
- Table: filter
- Chain INPUT (policy ACCEPT)
- num target prot opt source destination
- ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
- ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
- ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
- ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
- ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
- ACCEPT all -- 0.0.0.0/ 0.0.0.0/
- ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
- REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
- Chain FORWARD (policy ACCEPT)
- num target prot opt source destination
- REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
- Chain OUTPUT (policy ACCEPT)
- num target prot opt source destination
- # 删除刚刚添加的端口
- # 这里我原先已经开放了3306端口,再次添加又增加了一个3306,所以显示2个3306,这里我将num为2的那个3306删除
- [root@ ~]# iptables -D INPUT
- # 查看防火墙的状态(奇怪的是我原本也开放的有80端口,莫名其妙没了...)
- [root@ ~]# iptables -L -n --line-number
- Chain INPUT (policy ACCEPT)
- num target prot opt source destination
- ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
- ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
- ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
- ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
- ACCEPT all -- 0.0.0.0/ 0.0.0.0/
- ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
- REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
- Chain FORWARD (policy ACCEPT)
- num target prot opt source destination
- REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
- Chain OUTPUT (policy ACCEPT)
- num target prot opt source destination
2、修改mysql表,允许远程访问
- # 登陆
- [root@ ~]# mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is
- Server version: 5.7.
- Copyright (c) , , 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
- ERROR (HY000): You must reset your password using ALTER USER statement before executing this statement.
- # 在设置远程登录原先是提示错误。百度一番,需要设置root密码,好吧,我原先是1234,现在还设置为1234
- mysql> SET PASSWORD = PASSWORD('');
- ERROR (HY000): Your password does not satisfy the current policy requirements
- # 发现是密码太脆弱,究其根本是由于mysql有密码验证的策略,那么这里设置一下
- # 设置密码强度检查等级为0,/LOW、/MEDIUM、/STRONG。
- mysql> set global validate_password_policy=;
- Query OK, rows affected (0.00 sec)
- # 设置密码长度:-->
- mysql> select @@validate_password_length;
- +----------------------------+
- | @@validate_password_length |
- +----------------------------+
- | |
- +----------------------------+
- row in set (0.00 sec)
- mysql> set global validate_password_length=;
- Query OK, rows affected (0.00 sec)
- mysql> select @@validate_password_length;
- +----------------------------+
- | @@validate_password_length |
- +----------------------------+
- | |
- +----------------------------+
- row in set (0.00 sec)
- # 设置密码为1234
- mysql> SET PASSWORD = PASSWORD('');
- Query OK, rows affected, warning (0.00 sec)
- # 设置允许远程访问
- mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
- Query OK, rows affected, warning (0.00 sec)
- # 刷新权限
- mysql> flush privileges;
- Query OK, rows affected (0.00 sec)
- # 退出
- mysql> exit;
- Bye
3、windows下远程连接vm12下centos6.9的mysql
- Microsoft Windows [版本 6.1.]
- 版权所有 (c) Microsoft Corporation。保留所有权利。
- C:\Users\Administrator>mysql -h 192.168.22.130 -u root -p
- Enter password: ****
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is
- Server version: 5.7. MySQL Community Server (GPL)
- Copyright (c) , , 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>
最后就问下:惊不惊喜?意不意外?
vm12下Centos6安装mysql5.7的更多相关文章
- centos6.7下 编译安装MySQL5.7
centos6.7下编译安装MySQL5.7 准备工作 #-----依赖包及MySQL和boost安装包----- #yum包安装: shell> yum -y install gcc-c++ ...
- CentOS6.5_64bit下编译安装MySQL-5.6.23
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/44785511 ************************************** ...
- Linux上centOs6+安装mysql5.7详细教程 - 前端小鱼塘
https://coyhom.github.io/ 人类的本质是复读机,作为一个非linux专业人员学习linux最好的办法是重复 环境centos6.5 版本5.7 1: 检测系统是否自带安装mys ...
- Linux(CentOS7)下二进制安装MySQL5.7.26
记录一下自己在 CentOS7 下二进制安装 MySQL5.7.26 的过程,之前使用 Linux(CentOS7)下rpm安装MySQL8.0.16 之后发现 rpm 方式安装不利于维护,也不利于单 ...
- CentOS6.x下yum安装MySQL5.5/5.6
1. 安装mysql-5.5的yum源 # rpm -ivh http://repo.mysql.com/yum/mysql-5.5-community/el/6/x86_64/mysql-commu ...
- centos6.5下yum安装mysql5.5
第一步就是看linu是否安装了mysql,经过rpm -qa|grep mysql查看到centos下安装了mysql5.1,那就开始卸载咯 2 接下来就是卸载mysql5.1了,命令:rpm -e ...
- centos6.6下编译安装mysql5.6之后启动失败:Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
今天在编译安装mysql5.6时候出现Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysq ...
- CentOS6.9 下编译安装MySQL5.7.19
官网:https://www.mysql.com/ 下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19.tar.gz 一.准备工作 ...
- centos下编译安装mysql5.6
CentOS 6.4下编译安装MySQL 5.6.14 参考:http://www.cnblogs.com/xiongpq/p/3384681.html 概述: CentOS 6.4下通过yum安装的 ...
随机推荐
- Laravel 测试教程
参考链接:https://laravel-news.com/seeding-data-testing 迁移文件 修改 database/migrations/2014_10_12_000000_cre ...
- 【Head First Java 读书笔记】(二)类与对象
前篇当中,代码都放在main()里面,那根本不是面向对象的做法. 椅子大战(对象如何改变你的一生) 程序规格: 在图形接口画出四方形,圆形和三角形,当用户点选图形时,图形需要顺时针转360度并依据形状 ...
- word 2013如何从某一页开始插入页码
把光标移入要插入页面的最前面 插入分页符 在要插入页码的页脚双击打开页脚设计 取消页脚和前面页眉的链接 插入页码
- ColorMatrixFilter色彩矩阵滤镜;
包 flash.filters 类 public final class ColorMatrixFilter 继承 ColorMatrixFilter BitmapFilter Object 使用 ...
- svm的第一个实例
用的数据集是uci机器学习库的数据 ‘iris.data’ from sklearn import svm import csv from sklearn.model_selection import ...
- 最近的一些零碎知识点,jquery遍历
1.使按钮无法点击 $(“#btn”).attr("disable",true); 2.返回上一个页面 history.back(-1); 3.$(this).siblings() ...
- Linux下抓包命令tcpdump
本文内容来源于网络 PS:tcpdump是一个用于截取网络分组,并输出分组内容的工具,简单说就是数据包抓包工具.tcpdump凭借强大的功能和灵活的截取策略,使其成为Linux系统下用于网络分析和问题 ...
- java处理中国气象数据,提取汇总陕西地区24小时各观测点的数据(csv格式)
1.先贴一下气象数据的csv源格式,由于数据内容较多,就放一部分(china_sites_20150102.csv) date,hour,type,1001A,1002A,1003A,1004A,10 ...
- loj #2051. 「HNOI2016」序列
#2051. 「HNOI2016」序列 题目描述 给定长度为 n nn 的序列:a1,a2,⋯,an a_1, a_2, \cdots , a_na1,a2,⋯,an,记为 a[1: ...
- 洛谷P3122 [USACO15FEB]圈住牛Fencing the Herd(计算几何+CDQ分治)
题面 传送门 题解 题目转化一下就是所有点都在直线\(Ax+By-C=0\)的同一侧,也就可以看做所有点代入\(Ax+By-C\)之后的值符号相同,我们只要维护每一个点代入直线之后的最大值和最小值,看 ...