zoukankan      html  css  js  c++  java
  • CentOS7安装MySQL5.6

    1.安装包准备(MySQL官网下载

    (1)查看MySQL是否安装,如果存在就先卸载

    [root@hadoop101 桌面]# rpm -qa|grep MySQL
    mysql-libs-5.1.73-7.el6.x86_64
    [root@hadoop101 桌面]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64

    (2)查看mariadb是否安装,如果存在就先卸载

    [root@hadoop1 mysql-libs]# rpm -qa|grep mariadb
    mariadb-libs-5.5.60-1.el7_5.x86_64
    [root@hadoop1 mysql-libs]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

    (3)上传mysql-libs.zip到hadoop102的/opt/software目录,并解压文件到当前目录

    [root@hadoop1 mysql-libs]# cd /opt/software
    [root@hadoop1 software]# ll
    total 75988
    -rw-r--r--. 1 root root 77807942 Aug 13 12:17 mysql-libs.zip
    [root@hadoop1 software]# unzip mysql-libs.zip 
    Archive:  mysql-libs.zip
       creating: mysql-libs/
      inflating: mysql-libs/MySQL-client-5.6.24-1.el6.x86_64.rpm  
      inflating: mysql-libs/mysql-connector-java-5.1.27.tar.gz  
      inflating: mysql-libs/MySQL-server-5.6.24-1.el6.x86_64.rpm  
    [root@hadoop1 software]# ll
    total 75992
    drwxr-xr-x. 2 root root     4096 Jun 26  2015 mysql-libs
    -rw-r--r--. 1 root root 77807942 Aug 13 12:17 mysql-libs.zip

    (4)进入到mysql-libs文件夹下

    [root@hadoop1 software]# cd mysql-libs/
    [root@hadoop1 mysql-libs]# ll
    total 76048
    -rw-r--r--. 1 root root 18509960 Mar 26  2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
    -rw-r--r--. 1 root root  3575135 Dec  1  2013 mysql-connector-java-5.1.27.tar.gz
    -rw-r--r--. 1 root root 55782196 Mar 26  2015 MySQL-server-5.6.24-1.el6.x86_64.rpm

    2.安装MySQL服务器

    (1)安装MySQL服务端

    [root@hadoop101 mysql-libs]# rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm

    (2)查看产生的随机密码

    [root@hadoop101 mysql-libs]# cat /root/.mysql_secret
    OEXaQuS8IWkG19Xs

    (3)查看MySQL状态

    [root@hadoop101 mysql-libs]# service mysql status

    (4)启动MySQL

    [root@hadoop101 mysql-libs]# service mysql start

    3.安装MySQL客户端

    (1)安装MySQL客户端

    [root@hadoop101 mysql-libs]# rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm

    (2)链接MySQL(密码替换成产生的随机密码)

    [root@hadoop101 mysql-libs]# mysql -uroot -pOEXaQuS8IWkG19Xs

    (3)修改密码('000000'替换成你设置的密码)

    mysql>SET PASSWORD=PASSWORD('000000');

    (4)退出MySQL

    mysql>exit

    4.MySQL中user表中主机配置

    配置只要是root用户+密码,在任何主机上都能登录MySQL数据库。

    (1)进入MySQL

    [root@hadoop101 mysql-libs]# mysql -uroot -p000000

    (2)显示数据库

    mysql>show databases;

    (3)使用MySQL数据库

    mysql>use mysql;

    (4)展示MySQL数据库中的所有表

    mysql>show tables;

    (5)展示user表的结构

    mysql>desc user;

    (6)查询user表

    mysql>select User, Host, Password from user;

    (7)修改user表,把Host表内容修改为%

    mysql>update user set host='%' where host='localhost';

    (8)删除root用户的其他host

    mysql>
    
    delete from user where Host='hadoop101';
    
    delete from user where Host='127.0.0.1';
    
    delete from user where Host='::1';

    (9)刷新

    mysql>flush privileges;

    (10)退出

    mysql>quit;

    linux下,MySQL默认的数据文档存储目录为/var/lib/mysql

    参考:https://www.jianshu.com/p/98b6c1cbcb50

  • 相关阅读:
    vector 向量容器用法祥解
    stdafx.h 的作用
    vector 利用swap 函数进行内存的释放 vector<int>().swap
    LPCTSTR LPCWSTR LPCSTR 含义
    Application->ProcessMessages();
    sizeof 和 strlen 的区别
    程序编译没错,运行报错:无法定位程序输入点GT_BufLaserFollowRatio(这是函数)于动态链接库GTS.DLL上
    用户登录注销功能
    在项目开发中经常用到的全局函数
    在项目开发中经常用到的全局函数2
  • 原文地址:https://www.cnblogs.com/MWCloud/p/11347089.html
Copyright © 2011-2022 走看看