fedora 下mysql root密码重置

<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } -->

首先启动mysql 服务

[han@localhost ~]$ sudo service mysqld start

启动 MySQL[ 确定]

 

看看mysql 服务有没有起来

[han@localhost ~]$ sudo netstat -tap |grep mysql

tcp 0 0 *:mysql *:* LISTEN 4386/mysqld

 

修改root 密码,因为我实在记不得了

[han@localhost ~]$ mysqladmin -u root password root

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'root'@'localhost' (using password: NO)'

 

报错,上网搜索解决方法,如下执行

[han@localhost ~]$ su

密码:

[root@localhost han]# /etc/init.d/mysqld stop

停止 MySQL[ 确定]

 

[root@localhost han]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[1] 4567

[root@localhost han]# nohup: ignoring input and redirecting stderr to stdout

Starting mysqld daemon with databases from /var/lib/mysql

mysql -u root mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.67 Source distribution

 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

mysql> UPDATE user SET Password=PASSWORD('root') where USER='root'

-> ;

Query OK, 0 rows affected (0.01 sec)

Rows matched: 0 Changed: 0 Warnings: 0

 

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

 

mysql> quit

Bye

[root@localhost han]# service mysqld restart

STOPPING server from pid file /var/run/mysqld/mysqld.pid

081220 20:37:36 mysqld ended

 

停止 MySQL[ 确定]

启动 MySQL[ 确定]

[1]+ Done mysqld_safe --user=mysql --skip-grant-tables --skip-networking

[root@localhost han]# mysql -u root -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 

出错,重试

[root@localhost han]# mysql -u root -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 

依然报错,再次上网搜索解决办法,执行如下

[root@localhost han]# /etc/init.d/mysql stop

bash: /etc/init.d/mysql: 没有那个文件或目录

 

拷贝的命令不对,fedoraubuntu 的命令不一样,在试

[root@localhost han]# /etc/init.d/mysqld stop

停止 MySQL[ 确定]

[root@localhost han]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[1] 4803

[root@localhost han]# nohup: ignoring input and redirecting stderr to stdout

Starting mysqld daemon with databases from /var/lib/mysql

mysql -u root mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.67 Source distribution

 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| test |

+--------------------+

3 rows in set (0.00 sec)

 

mysql> use mysql

Database changed

mysql> show tables;

+---------------------------+

| Tables_in_mysql |

+---------------------------+

| columns_priv |

| db |

| func |

| help_category |

| help_keyword |

| help_relation |

| help_topic |

| host |

| proc |

| procs_priv |

| tables_priv |

| time_zone |

| time_zone_leap_second |

| time_zone_name |

| time_zone_transition |

| time_zone_transition_type |

| user |

+---------------------------+

17 rows in set (0.00 sec)

 

mysql> UPDATE user SET Password=PASSWORD('root') where USER='root';

Query OK, 0 rows affected (0.00 sec)

Rows matched: 0 Changed: 0 Warnings: 0

 

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

 

mysql> quit

Bye

[root@localhost han]# killall -9 mysqld

/usr/bin/mysqld_safe: line 388: 4842 已杀死 nohup /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock --skip-grant-tables --skip-networking >> /var/log/mysqld.log 2>&1

[root@localhost han]#

Number of processes running now: 0

081220 20:43:36 mysqld restarted

 

[root@localhost han]# /etc/init.d/mysqld start

启动 MySQL[ 确定]

[root@localhost han]# mysql -u root -p

Enter password:

 

终于使用root 密码进来了!

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.0.67 Source distribution

 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

图形工具使用root/root连接

成功登录

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值