查看文章 |
mysql忘记root密码
2008-04-04 14:05
忘记root口令是的处理方法: [root@localhost data]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [root@localhost data]# su - mysql [mysql@localhost ~]$ /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip -networking & [1] 3019 [mysql@localhost ~]$ Starting mysqld daemon with databases from /usr/local/mysql/var [mysql@localhost ~]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 5.0.24a-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+ | Database | +--------------------+ | information_schema | | library | | mysql | | test | +--------------------+ 4 rows in set (0.01 sec) mysql> 这样就可以绕过授权表,作为mysql根用户登陆到服务器,不需要输入口令,额外的参数--skip-networking选项告诉mysql不要监听tcp/ip的连接,并且保证不回在修改权限时在网络上被破解。下面的动作是修改root的口令: mysql> use mysql Database changed mysql> update user set password=password('123123') where user='root'; Query OK, 1 row affected (0.04 sec) Rows matched: 2 Changed: 1 Warnings: 0 下面的步骤就是关闭数据库,按照正常的方式启动。 |
最近读者: