linux下如何修改Mysql的root密码
    今天,忘了mysql下的root密码,想重置一下,但找了多个网站上的方法均有问题,最后参考几家的过程,经过不断尝试获得,终于成功了,下面特将过程分享给大家:
环境:
操作系统:Centos 5.5
数据库:MySQL 5.0.77
  
过程:
1、关闭mysql。
[root@localhost ~]#service mysqld stop
Stopping MySQL:                                            [  OK  ]
 
2、跳过授权表启动mysql,关闭网络监听,让其后台运行或者开个新终端。 
[root@localhost ~]#mysqld_safe --skip-grant-tables --skip-networking
Starting mysqld daemon with databases from /var/lib/mysql
提示:此时按下CTRL-Z
 
[1]+  Stopped                 mysqld_safe --skip-grant-tables --skip-networking
[root@localhost ~]#bg
[1]+ mysqld_safe --skip-grant-tables --skip-networking &
 
3、链接mysql服务器。 
[root@localhost ~]#mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
 
4、使用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
 
5、设置root新密码。
mysql>update user set password=password('123') where user='root';
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3  Changed: 3  Warnings: 0
 
6、退出mysql。
mysql>quit
bye
  
7、重起mysql。
[root@localhost ~]#service mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
120928 11:38:28  mysqld ended
 
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables --skip-networking
 
 
现在你可以使用新的密码登录mysql了。

Linux下修改MySql的root密码的更多相关文章

  1. 在linux下修改mysql的root密码

    第一种方法: root用户登录系统 /usr/local/mysql/bin/mysqladmin -u root -p password 新密码 enter password 旧密码 第二种方法: ...

  2. Linux下忘记MySQL的root密码的解决方法

    恢复方法之一 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也 ...

  3. 在Linux系统环境下修改MySQL的root密码

    root用户登录系统 /usr/local/mysql/bin/mysqladmin -u root -p password 新密码 enter password 旧密码 第二种方法: root用户登 ...

  4. windows环境下修改Mysql的root密码

    最近一直没用Mysql,root密码给忘了,然后就自己修改了一下,现在整理一下步骤.(我的版本是5.1) 启动MySQL服务:>>net start mysql 关闭MySQL服务:> ...

  5. linux下重置mysql的root密码

    # /etc/init.d/mysql stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # my ...

  6. linux下忘记mysql的root密码

    一.处理方案 #1. 结束当前正在运行的mysql进程 /etc/init.d/mysql stop #2. 用mysql安全模式运行并跳过权限验证 mysqld_safe --user=mysql ...

  7. windows环境下,mysql的root密码丢失后重置方法

    运行窗口输入 services.msc,检查mysql服务是否启动,如果启动手动停止或输入 net stop mysql 停止msyql服务.   打开cmd命令行,使用cd命令进入mysql 的bi ...

  8. 阿里云linux下修改mysql默认密码(xampp环境)- 原创

    1.修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/my ...

  9. linux下mysql5.7忘记root密码修改

    朋友最近开始学服务器,mysql密码忘了又不会弄,让我帮忙解决一下.重置或修改mysql的root密码这种事平时很少做,还是得google辅助一下,于是弄完了写篇博客记录一下,方便若干月后又有人遇到这 ...

随机推荐

  1. mac电脑的系统偏好设置的安全与隐私的任何来源没有了

    打开电脑搜索   输入终端   打开终端输入 sudo spctl --master-disable

  2. Servlet实例开发---学生管理系统

    Servlet总结 本程序采用Servlet开发技术,MVC分层,所有程序在设计时都要接口为操作的标准,主要逻辑操作只有增删改查. 具体实现操作请看源代码. 本程序采用的是MYSQL数据库,需加入相应 ...

  3. HTTP Status 500 PWC6188 jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

    报错如下: 解决方案: 1.可能是依赖引用错了,注意 JSP 应依赖: <!-- JSP --> <dependency> <groupId>javax.servl ...

  4. Linux环境下NodeJS和MongoDB的安装配置

     一.NodeJS的安装配置 #进入安装目录cd /usr/local/ #删除原有安装rm -rf noderm -rf node-v0.10.29-linux-x64 #解压压缩包tar -zxv ...

  5. 防简单攻击iptables策略

    #!/bin/sh IPTABLES=/sbin/iptables # clear $IPTABLES -F # if pkg type is allow, then accept #$IPTABLE ...

  6. 从PCD文件写入和读取点云数据

    (1)学习向PCD文件写入点云数据 建立工程文件ch2,然后新建write_pcd.cpp  CMakeLists.txt两个文件 write_pcd.cpp : #include <iostr ...

  7. C#里的SubString和Convert.ToDateTime

    1.C#里的SubString String.SubString(int   index,int   length) index:开始位置,从0开始 length:你要取的子字符串的长度 2.C#语言 ...

  8. export Jar from eclipse (总结)

    sourceforge 的源码网址 :https://sourceforge.net/projects/fjep/files/fatjar/ <span style="margin:0 ...

  9. svn解决不能clean的方法

    http://blog.csdn.net/victory08/article/details/42100325 svn执行clean up后出现提示:svn cleanup failed–previo ...

  10. TP Rate ,FP Rate, Precision, Recall, F-Measure, ROC Area,

    TP Rate ,FP Rate, Precision, Recall, F-Measure, ROC Area, https://www.zhihu.com/question/30643044 T/ ...