码迷,mamicode.com
首页 > 数据库 > 详细

linux下mysql密码破解的方法

时间:2015-07-09 22:57:51      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:mysql

a.

  1. 首先停止服务/etc/init.d/mysqld stop,在/etc/my.cnf中添加:

    socket=/var/lib/mysql/mysql.sock
    skip-grant-tables
    user=mysql

  2. 启动mysql服务,输入mysql登陆

  3. mysql> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

  4. Database changed
    mysql> update user set password=password (‘lixi‘) where user=‘root‘;
    Query OK, 3 rows affected (0.02 sec)
    Rows matched: 3  Changed: 3  Warnings: 0

  5. mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)

  6. 修改完后重启mysql然后在以自己修改的密码登陆就ok了

b.源码安装mysql及密码破解

  1. root@192_168_2_193 ~]# cat /etc/issue
    CentOS release 6.4 (Final)
    Kernel \r on an \m

  2. [root@192_168_2_193 ~]# uname -r
    2.6.32-358.el6.x86_64

  3. mysql下载wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.63.tar.gz

  4. tar xzf mysql-5.1.63.tar.gz ;cd mysql-5.1.63 ;./configure --prefix=/usr/local/mysql
    --enable-assembler &&make -j8&&make -j8 install

  5. 配置mysql为系统服务

  6. cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
    cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
    chkconfig --add mysqld
    chkconfig --level 35 mysqld on
    /etc/init.d/mysqld restart

  7. 设置相关参数及初始化数据库

  8.  useradd mysql
    chown -R mysql.mysql /usr/local/mysql
    /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=./var
    --basedir=/usr/local/mysql/
    chown -R mysql.mysql var
    /usr/local/mysql/bin/mysqld_safe --user=mysql &

  9. /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables &跳过权限启动后台

  10. /usr/local/mysql/bin/mysql 登陆 use mysql;update user set password=password(‘lixi‘) where user=‘root‘;flush privileges;/etc/init.d/mysqld restart

本文出自 “毛毛鸭” 博客,请务必保留此出处http://woshitieren.blog.51cto.com/2466034/1672546

linux下mysql密码破解的方法

标签:mysql

原文地址:http://woshitieren.blog.51cto.com/2466034/1672546

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!