zoukankan      html  css  js  c++  java
  • linux环境下Mysql的卸载和重新安装和启动

    MySql安装

    1 安装包准备

    1.查看mysql是否安装,如果安装了,卸载mysql

    1)查看

    [root@hadoop102 桌面]# rpm -qa|grep mysql
    mysql-libs-5.1.73-7.el6.x86_64

    2)卸载

    [root@hadoop102 桌面]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64

    2.解压mysql-libs.zip文件到当前目录

    [root@hadoop102 software]# unzip mysql-libs.zip
    
    [root@hadoop102 software]# ls
    
    mysql-libs.zip
    
    mysql-libs

    3.进入到mysql-libs文件夹下

    [root@hadoop102 mysql-libs]# ll
    
    总用量 76048
    
    -rw-r--r--. 1 root root 18509960 3月  26 2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
    
    -rw-r--r--. 1 root root  3575135 12月  1 2013 mysql-connector-java-5.1.27.tar.gz
    
    -rw-r--r--. 1 root root 55782196 3月  26 2015 MySQL-server-5.6.24-1.el6.x86_64.rpm

    2 安装MySql服务器

    1.安装mysql服务端

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

    2.查看产生的随机密码

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

    3.查看mysql状态

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

    4.启动mysql

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

    3 安装MySql客户端

    1.安装mysql客户端

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

    2.链接mysql

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

    3.修改密码

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

    4.退出mysql

    mysql>exit

    4 MySqluser表中主机配置

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

    1.进入mysql
    
    [root@hadoop102 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='hadoop102';
    
    mysql>delete from user where Host='127.0.0.1';
    
    mysql>delete from user where Host='::1';
    
    9.刷新
    
    mysql>flush privileges;
    
    10.退出
    
    mysql>quit;
  • 相关阅读:
    libcurl进行HTTP GET获取JSON数据(转载)
    c/c++ 动态申请数组(转载)
    利用注册表写开机启动程序(转载)
    VC++使用IMAPI调用Outlook邮箱客户端和Foxmail邮箱客户端遇到的问题
    解决Duilib集成CEF浏览器在Win10无法向客户区拖拽文件
    解决往监控目录拖拽文件夹无法监控到的问题
    VC++ 实现修改文件创建、访问、修改时间属性(转载)
    Windows中的时间(SYSTEMTIME和FILETIME) (转载)
    ThinkPHP真正疑难问题笔记
    git版本控制管理实践-4
  • 原文地址:https://www.cnblogs.com/alexzhang92/p/10638806.html
Copyright © 2011-2022 走看看