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. Web基础 HTML CSS JS JQuery AJAX

    1. Web基础 网页的骨骼HTML 什么是HTML超文本标记语言:Hyper Text Markup Language 这都不重要,重要的是:HTML是Web网页的基本组成部分HTML中定义的元素, ...

  2. 愿Linux红帽旋风吹得更加猛烈吧!

    大约在2000年年初.<中国青年出版社>准备从台湾引进图书(中译本)"Linux红帽旋风"(美国Robert Young),让我为该书写一个前言. 该书作者罗伯特.扬是 ...

  3. 在IIS中访问APS页面时提示:“最可能的原因使用的托管的处理程序,但是未安装或未完整安装asp.net“

    打开CMD窗口,执行下面的命令: "%WINDIR%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe" -iru -ena ...

  4. mysqldump具体应用实例

    1.导出整个数据库  mysqldump -h主机 -u 用户名 -p 数据库名 > 导出的文件名      mysqldump -h127.0.0.1 -u wcnc -p smgp_apps ...

  5. InstallShield Build错误:Internal build error 6041

    点击左侧菜单: Media-Release-选择release版本(例如Release1)-Build标签-   keey unused directories 改为no(默认为yes)

  6. C语言 · Quadratic Equation

    算法提高 Quadratic Equation   时间限制:1.0s   内存限制:512.0MB      问题描述 求解方程ax2+bx+c=0的根.要求a, b, c由用户输入,并且可以为任意 ...

  7. 【oneday_onepage】——Growth Is A Bitch

    Companies are worth a multiple of their earnings and that multiple is directly related to earnings g ...

  8. iOS 实时音频采集与播放Audio Unit使用

    前言 在iOS中有很多方法可以进行音视频采集.如 AVCaptureDevice, AudioQueue以及Audio Unit.其中 Audio Unit是最底层的接口,它的优点是功能强大,延迟低; ...

  9. 微信小程序的json遍历

    入门教程之列表渲染多层嵌套循环,目前官方的文档里,主要是一维数组列表渲染的案例,还是比较简单单一,给刚入门的童鞋还是无从入手的感觉. <view wx:for="{{items}}&q ...

  10. CentOS执行ping命令报错 name or service not know

    在虚拟机上安装的CentOS,但是当执行ping命令的时候,提示name or service not known 解决方法如下: 1. 添加DNS服务器 vi /etc/resolv.conf 1 ...