一、下载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、解压

  1. # 将mysql-5.7.-.el6.x86_64.rpm-bundle.tar压缩包解压到/usr/wangzf/mysqlrpm/下
  2. [root@localhost downloads]# tar -xvf mysql-5.7.-.el6.x86_64.rpm-bundle.tar -C ../mysqlrpm/
  3. mysql-community-libs-compat-5.7.-.el6.x86_64.rpm
  4. mysql-community-test-5.7.-.el6.x86_64.rpm
  5. mysql-community-libs-5.7.-.el6.x86_64.rpm
  6. mysql-community-common-5.7.-.el6.x86_64.rpm
  7. mysql-community-embedded-5.7.-.el6.x86_64.rpm
  8. mysql-community-embedded-devel-5.7.-.el6.x86_64.rpm
  9. mysql-community-client-5.7.-.el6.x86_64.rpm
  10. mysql-community-devel-5.7.-.el6.x86_64.rpm
  11. mysql-community-server-5.7.-.el6.x86_64.rpm
  12.  
  13. # 查看解压后的rpm软件包
  14. [root@localhost downloads]# cd ../mysqlrpm/
  15. [root@localhost mysqlrpm]# ll
  16. total
  17. -rw-r--r--. Mar : mysql-community-client-5.7.-.el6.x86_64.rpm
  18. -rw-r--r--. Mar : mysql-community-common-5.7.-.el6.x86_64.rpm
  19. -rw-r--r--. Mar : mysql-community-devel-5.7.-.el6.x86_64.rpm
  20. -rw-r--r--. Mar : mysql-community-embedded-5.7.-.el6.x86_64.rpm
  21. -rw-r--r--. Mar : mysql-community-embedded-devel-5.7.-.el6.x86_64.rpm
  22. -rw-r--r--. Mar : mysql-community-libs-5.7.-.el6.x86_64.rpm
  23. -rw-r--r--. Mar : mysql-community-libs-compat-5.7.-.el6.x86_64.rpm
  24. -rw-r--r--. Mar : mysql-community-server-5.7.-.el6.x86_64.rpm
  25. -rw-r--r--. Mar : mysql-community-test-5.7.-.el6.x86_64.rpm

2、安装mysql

  1. # 想要安装mysqlclient和mysqlserver,需要先安装common和libs
  2. [root@localhost mysqlrpm]# rpm -ivh mysql-community-common-5.7.-.el6.x86_64.rpm
  3. Preparing... ########################################### [%]
  4. :mysql-community-common ########################################### [%]
  5. [root@localhost mysqlrpm]# rpm -ivh mysql-community-libs-5.7.-.el6.x86_64.rpm
  6. Preparing... ########################################### [%]
  7. :mysql-community-libs ########################################### [%]
  8. [root@localhost mysqlrpm]# rpm -ivh mysql-community-client-5.7.-.el6.x86_64.rpm
  9. Preparing... ########################################### [%]
  10. :mysql-community-client ########################################### [%]
  11. [root@localhost mysqlrpm]# rpm -ivh mysql-community-server-5.7.-.el6.x86_64.rpm
  12. Preparing... ########################################### [%]
  13. :mysql-community-server ########################################### [%]
  14.  
  15. # 查看已安装的与mysql相关的软件
  16. [root@localhost mysqlrpm]# rpm -qa|grep -i mysql
  17. mysql-community-common-5.7.-.el6.x86_64
  18. mysql-community-client-5.7.-.el6.x86_64
  19. mysql-community-libs-5.7.-.el6.x86_64
  20. mysql-community-server-5.7.-.el6.x86_64

安装异常处理:

  1. # 如果出现以下错误,请先安装perl、libnuma
  2. [root@slave01 mysqlrpm]# rpm -ivh mysql-community-server-5.7.-.el6.x86_64.rpm
  3. warning: mysql-community-server-5.7.-.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
  4. error: Failed dependencies:
  5. /usr/bin/perl is needed by mysql-community-server-5.7.-.el6.x86_64
  6. libnuma.so.()(64bit) is needed by mysql-community-server-5.7.-.el6.x86_64
  7. libnuma.so.(libnuma_1.)(64bit) is needed by mysql-community-server-5.7.-.el6.x86_64
  8. libnuma.so.(libnuma_1.)(64bit) is needed by mysql-community-server-5.7.-.el6.x86_64
  9. perl(File::Path) is needed by mysql-community-server-5.7.-.el6.x86_64
  10. perl(Getopt::Long) is needed by mysql-community-server-5.7.-.el6.x86_64
  11. perl(POSIX) is needed by mysql-community-server-5.7.-.el6.x86_64
  12. perl(strict) is needed by mysql-community-server-5.7.-.el6.x86_64
  13.  
  14. [root@slave01 mysqlrpm]# yum install perl
  15. [root@slave01 mysqlrpm]# yum install libnuma*

3、启动mysql

  1. # 查看mysql服务的状态
  2. [root@localhost mysqlrpm]# service mysqld status
  3. mysqld is stopped
  4.  
  5. # mysql尚未启动,使用service mysqld start启动(这里是第一次启动,会初始化一些参数)
  6. [root@localhost mysqlrpm]# service mysqld start
  7. Initializing MySQL database: [ OK ]
  8. Installing validate password plugin: [ OK ]
  9. Starting mysqld: [ OK ]
  10.  
  11. # 停止mysql服务
  12. [root@localhost mysqlrpm]# service mysqld stop
  13. Stopping mysqld: [ OK ]
  14.  
  15. # 启动mysql服务
  16. [root@localhost mysqlrpm]# service mysqld start
  17. Starting mysqld: [ OK ]
  18.  
  19. # 重启mysql服务
  20. [root@localhost mysqlrpm]# service mysqld restart
  21. Stopping mysqld: [ OK ]
  22. Starting mysqld: [ OK ]

四、修改root密码

  1. # 关闭mysql服务
  2. [root@localhost ~]# service mysqld stop
  3. Stopping mysqld: [ OK ]
  4.  
  5. # 安全模式下启动mysql,并且跳过权限表的验证
  6. [root@ ~]# mysqld_safe --skip-grant-tables &
  7. []
  8. [root@ ~]# --06T23::.604144Z mysqld_safe Logging to '/var/log/mysqld.log'.
  9. --06T23::.674987Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  10.  
  11. # 准备登陆
  12. mysql -u root -p
  13.  
  14. # 这里随便输入密码,都可以进入mysql
  15. Enter password:
  16. Welcome to the MySQL monitor. Commands end with ; or \g.
  17. Your MySQL connection id is
  18. Server version: 5.7. MySQL Community Server (GPL)
  19.  
  20. Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
  21.  
  22. Oracle is a registered trademark of Oracle Corporation and/or its
  23. affiliates. Other names may be trademarks of their respective
  24. owners.
  25.  
  26. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  27.  
  28. # 更改密码(这里设置的密码是1234)
  29. mysql> update mysql.user set authentication_string=password('') where user='root' and Host = 'localhost';
  30. Query OK, row affected, warning (0.04 sec)
  31. Rows matched: Changed: Warnings:
  32.  
  33. # 刷新权限
  34. mysql> flush privileges;
  35. Query OK, rows affected (0.00 sec)
  36.  
  37. # 退出mysql
  38. mysql> quit
  39. Bye
  40.  
  41. # 重启mysql
  42. [root@localhost ~]# service mysqld restart
  43. --06T23::.067045Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
  44. Stopping mysqld: [ OK ]
  45. Starting mysqld: [ OK ]
  46. []- Done mysqld_safe --skip-grant-tables
  47.  
  48. # 以root身份登陆
  49. [root@localhost ~]# mysql -uroot -p
  50.  
  51. # 输入刚才设置的密码1234,正常使用mysql
  52. Enter password:
  53. Welcome to the MySQL monitor. Commands end with ; or \g.
  54. Your MySQL connection id is
  55. Server version: 5.7.
  56.  
  57. Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
  58.  
  59. Oracle is a registered trademark of Oracle Corporation and/or its
  60. affiliates. Other names may be trademarks of their respective
  61. owners.
  62.  
  63. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  64.  
  65. mysql>

五、远程访问mysql

1、centos开启防火墙端口3306

  1. # 开放3306端口
  2. [root@ ~]# /sbin/iptables -I INPUT -p tcp --dport -j ACCEPT
  3.  
  4. # 保存
  5. [root@ ~]# /etc/rc.d/init.d/iptables save
  6. iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
  7.  
  8. # 查看防火墙的状态
  9. [root@ ~]# /etc/init.d/iptables status
  10. Table: filter
  11. Chain INPUT (policy ACCEPT)
  12. num target prot opt source destination
  13. ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
  14. ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
  15. ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
  16. ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
  17. ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
  18. ACCEPT all -- 0.0.0.0/ 0.0.0.0/
  19. ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
  20. REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
  21.  
  22. Chain FORWARD (policy ACCEPT)
  23. num target prot opt source destination
  24. REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
  25.  
  26. Chain OUTPUT (policy ACCEPT)
  27. num target prot opt source destination
  28.  
  29. # 删除刚刚添加的端口
  30. # 这里我原先已经开放了3306端口,再次添加又增加了一个3306,所以显示2个3306,这里我将num为2的那个3306删除
  31. [root@ ~]# iptables -D INPUT
  32.  
  33. # 查看防火墙的状态(奇怪的是我原本也开放的有80端口,莫名其妙没了...)
  34. [root@ ~]# iptables -L -n --line-number
  35. Chain INPUT (policy ACCEPT)
  36. num target prot opt source destination
  37. ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
  38. ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
  39. ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
  40. ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
  41. ACCEPT all -- 0.0.0.0/ 0.0.0.0/
  42. ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
  43. REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
  44.  
  45. Chain FORWARD (policy ACCEPT)
  46. num target prot opt source destination
  47. REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
  48.  
  49. Chain OUTPUT (policy ACCEPT)
  50. num target prot opt source destination

2、修改mysql表,允许远程访问

  1. # 登陆
  2. [root@ ~]# mysql -uroot -p
  3. Enter password:
  4. Welcome to the MySQL monitor. Commands end with ; or \g.
  5. Your MySQL connection id is
  6. Server version: 5.7.
  7.  
  8. Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
  9.  
  10. Oracle is a registered trademark of Oracle Corporation and/or its
  11. affiliates. Other names may be trademarks of their respective
  12. owners.
  13.  
  14. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  15.  
  16. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
  17. ERROR (HY000): You must reset your password using ALTER USER statement before executing this statement.
  18.  
  19. # 在设置远程登录原先是提示错误。百度一番,需要设置root密码,好吧,我原先是1234,现在还设置为1234
  20. mysql> SET PASSWORD = PASSWORD('');
  21. ERROR (HY000): Your password does not satisfy the current policy requirements
  22.  
  23. # 发现是密码太脆弱,究其根本是由于mysql有密码验证的策略,那么这里设置一下
  24. # 设置密码强度检查等级为0,/LOW、/MEDIUM、/STRONG。
  25. mysql> set global validate_password_policy=;
  26. Query OK, rows affected (0.00 sec)
  27.  
  28. # 设置密码长度:-->
  29. mysql> select @@validate_password_length;
  30. +----------------------------+
  31. | @@validate_password_length |
  32. +----------------------------+
  33. | |
  34. +----------------------------+
  35. row in set (0.00 sec)
  36.  
  37. mysql> set global validate_password_length=;
  38. Query OK, rows affected (0.00 sec)
  39.  
  40. mysql> select @@validate_password_length;
  41. +----------------------------+
  42. | @@validate_password_length |
  43. +----------------------------+
  44. | |
  45. +----------------------------+
  46. row in set (0.00 sec)
  47.  
  48. # 设置密码为1234
  49. mysql> SET PASSWORD = PASSWORD('');
  50. Query OK, rows affected, warning (0.00 sec)
  51.  
  52. # 设置允许远程访问
  53. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
  54. Query OK, rows affected, warning (0.00 sec)
  55.  
  56. # 刷新权限
  57. mysql> flush privileges;
  58. Query OK, rows affected (0.00 sec)
  59. # 退出
  60. mysql> exit;
  61. Bye

3、windows下远程连接vm12下centos6.9的mysql

  1. Microsoft Windows [版本 6.1.]
  2. 版权所有 (c) Microsoft Corporation。保留所有权利。
  3.  
  4. C:\Users\Administrator>mysql -h 192.168.22.130 -u root -p
  5. Enter password: ****
  6. Welcome to the MySQL monitor. Commands end with ; or \g.
  7. Your MySQL connection id is
  8. Server version: 5.7. MySQL Community Server (GPL)
  9.  
  10. Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
  11.  
  12. Oracle is a registered trademark of Oracle Corporation and/or its
  13. affiliates. Other names may be trademarks of their respective
  14. owners.
  15.  
  16. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  17.  
  18. mysql>

最后就问下:惊不惊喜?意不意外?

vm12下Centos6安装mysql5.7的更多相关文章

  1. centos6.7下 编译安装MySQL5.7

    centos6.7下编译安装MySQL5.7 准备工作 #-----依赖包及MySQL和boost安装包----- #yum包安装: shell> yum -y install gcc-c++ ...

  2. CentOS6.5_64bit下编译安装MySQL-5.6.23

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/44785511 ************************************** ...

  3. Linux上centOs6+安装mysql5.7详细教程 - 前端小鱼塘

    https://coyhom.github.io/ 人类的本质是复读机,作为一个非linux专业人员学习linux最好的办法是重复 环境centos6.5 版本5.7 1: 检测系统是否自带安装mys ...

  4. Linux(CentOS7)下二进制安装MySQL5.7.26

    记录一下自己在 CentOS7 下二进制安装 MySQL5.7.26 的过程,之前使用 Linux(CentOS7)下rpm安装MySQL8.0.16 之后发现 rpm 方式安装不利于维护,也不利于单 ...

  5. 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 ...

  6. centos6.5下yum安装mysql5.5

    第一步就是看linu是否安装了mysql,经过rpm -qa|grep mysql查看到centos下安装了mysql5.1,那就开始卸载咯 2 接下来就是卸载mysql5.1了,命令:rpm -e ...

  7. 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 ...

  8. CentOS6.9 下编译安装MySQL5.7.19

    官网:https://www.mysql.com/ 下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19.tar.gz 一.准备工作 ...

  9. centos下编译安装mysql5.6

    CentOS 6.4下编译安装MySQL 5.6.14 参考:http://www.cnblogs.com/xiongpq/p/3384681.html 概述: CentOS 6.4下通过yum安装的 ...

随机推荐

  1. Laravel 测试教程

    参考链接:https://laravel-news.com/seeding-data-testing 迁移文件 修改 database/migrations/2014_10_12_000000_cre ...

  2. 【Head First Java 读书笔记】(二)类与对象

    前篇当中,代码都放在main()里面,那根本不是面向对象的做法. 椅子大战(对象如何改变你的一生) 程序规格: 在图形接口画出四方形,圆形和三角形,当用户点选图形时,图形需要顺时针转360度并依据形状 ...

  3. word 2013如何从某一页开始插入页码

    把光标移入要插入页面的最前面 插入分页符 在要插入页码的页脚双击打开页脚设计 取消页脚和前面页眉的链接 插入页码

  4. ColorMatrixFilter色彩矩阵滤镜;

    包 flash.filters 类 public final class ColorMatrixFilter 继承 ColorMatrixFilter  BitmapFilter  Object 使用 ...

  5. svm的第一个实例

    用的数据集是uci机器学习库的数据 ‘iris.data’ from sklearn import svm import csv from sklearn.model_selection import ...

  6. 最近的一些零碎知识点,jquery遍历

    1.使按钮无法点击 $(“#btn”).attr("disable",true); 2.返回上一个页面 history.back(-1); 3.$(this).siblings() ...

  7. Linux下抓包命令tcpdump

    本文内容来源于网络 PS:tcpdump是一个用于截取网络分组,并输出分组内容的工具,简单说就是数据包抓包工具.tcpdump凭借强大的功能和灵活的截取策略,使其成为Linux系统下用于网络分析和问题 ...

  8. java处理中国气象数据,提取汇总陕西地区24小时各观测点的数据(csv格式)

    1.先贴一下气象数据的csv源格式,由于数据内容较多,就放一部分(china_sites_20150102.csv) date,hour,type,1001A,1002A,1003A,1004A,10 ...

  9. loj #2051. 「HNOI2016」序列

    #2051. 「HNOI2016」序列 题目描述 给定长度为 n nn 的序列:a1,a2,⋯,an a_1, a_2, \cdots , a_na​1​​,a​2​​,⋯,a​n​​,记为 a[1: ...

  10. 洛谷P3122 [USACO15FEB]圈住牛Fencing the Herd(计算几何+CDQ分治)

    题面 传送门 题解 题目转化一下就是所有点都在直线\(Ax+By-C=0\)的同一侧,也就可以看做所有点代入\(Ax+By-C\)之后的值符号相同,我们只要维护每一个点代入直线之后的最大值和最小值,看 ...