mysql忘记root密码,不要急

  1. 跳过授权

    vi /etc/my.cnf

    在[mysqld]的段中加上一句:skip-grant-tables

    例如:

    [mysqld]

    datadir=/var/lib/mysql

    socket=/var/lib/mysql/mysql.sock

    skip-grant-tables

  2. 重启mysql

  3. 登陆mysql

    # /usr/bin/mysql

    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

    Database changed

    mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;

    Query OK, 0 rows affected (0.00 sec)

    Rows matched: 2 Changed: 0 Warnings: 0

    mysql> flush privileges ;

    Query OK, 0 rows affected (0.01 sec)

    mysql> quit

    Bye

  4. 去配置文件删除skip-grant-tables

  5. 重启mysql就可以了

    mysql忘记root密码,不要急

评论

目前评论:0   

点击加载更多评