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. JAVA 生成无重复8位随机码(转)

    转载自:https://my.oschina.net/vvcumt/blog/491504 短8位UUID思想其实借鉴微博短域名的生成方式,但是其重复概率过高,而且每次生成4个,需要随即选取一个. 本 ...

  2. python 基础总计 2

    6.函数:      match.sqrt(),lower(),len(),type(),isinstance('a',str),max(),min(),dir(),hex(),setattar(ob ...

  3. java基础解疑!!!

    疑问一:0.01+0.09的结果? public class MathTest{ public static void main(String[]args){ double a = 0.01, b = ...

  4. 用Total Commander for Android管理应用程序

    用Total Commander for Android管理应用程序 前不久安装了一个Total Commander的Anroid版本,除了用它来管理文件之外,我发现用它管理已安装程序挺不错的. 可以 ...

  5. [转]httpclient编码

    这几天都在纠结Java Web开发中的中文编码问题.其实,很多Java Web开发者都被中文编码“折磨”过,网络上有大量的讨论.以前我也读过这方面的博文,读完后感觉似乎懂了,好像知道了编码问题的原因和 ...

  6. InstallShield卸载状态

    uninstallaing() 它对应于-unistall 命令,在installshield 2009及之前的版本,在控制面板中选择"uninstall”会触发这个命令.但在install ...

  7. Android——计算器第一次完善

    完善: 1- 处理首位为0 2- 处理首位为“.” 3- 处理前两位为“0.”,此时首位为0,但是不能处理 4- 处理小数点不能重复输入 发现bug:12.3x6 = 如下图: xml <?xm ...

  8. Vagrant (2) —— 基本安装与配置(下)

    Vagrant (2) -- 基本安装与配置(下) 摘要 基本安装与配置 版本 Vagrant版本: 1.8.1 内容 预置 我们可以通SSH登录然后安装一个web服务器,但是这样每个使用Vagran ...

  9. WCF 几种错误

    1.错误  SOAP 的安全协商失败  SOAP Message=X.509 证书 CN=qq-PC 不在被信任的人的存储中. 将整数导入到配置文件指定的存储区中的受信任人. 2.从另一方收到未进行安 ...

  10. log_bin_trust_function_creators

    log_bin_trust_function_creators错误解决 当有mysql本地或远程建立function或procedure时报上面的错误 或者如果开启了二进制日志,但是用户没有suppe ...