Centos下忘记mysql的root密码的解决方法

一:(停掉正在运行的mysql)
[root@NetDakVPS ~]# service mysql
stop

二:使用
“--skip-grant-tables”
参数重新启动mysql
[root@NetDakVPS ~]# mysqld_safe --skip-grant-tables
&

[1] 23810
Starting mysqld daemon with databases from
/var/lib/mysql

三:用root帐号登录mysql
[root@NetDakVPS ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or
\g.

Your MySQL connection id is 1
Server version: 5.0.77 Source distributionType 'help;'
or '\h' for help. Type '\c' to clear the buffer.

四:改变用户数据库
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 -ADatabase changed

五:修改密码,记得密码要用password()函数进行加密
mysql> update user set password=password('netdak')
where user='root';

Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
六:刷新权限表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
七:退出mysql
mysql> quit
Bye
八:对mysql进行重启
[root@NetDakVPS ~]# service mysql restart;
STOPPING server from pid file
/var/run/mysqld/mysqld.pid

100421 13:44:03 mysqld endedStopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[1]+ Done mysqld_safe --skip-grant-tables
九:用更改过的密码重新登录即可。
[root@NetDakVPS ~]# mysql -u root -p
Enter password: netdak
Welcome to the MySQL monitor. Commands end with ; or
\g.

Your MySQL connection id is 2
Server version: 5.0.77 Source distributionType 'help;'
or '\h' for help. Type '\c' to clear the buffer.mysql> quit

Bye

十、重新执行修改密码

SET PASSWORD = PASSWORD('123456');

注:第十步不一定需要,但是 MySql5.6操作时可能会报错:You must SET PASSWORD before executing this statement.

Centos下忘记mysql的root密码的解决方法的更多相关文章

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

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

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

    经常会有朋友或者同事问起,MySQL 的 root 密码忘了,不知道改怎么办. 其实解决方法很简单,下面是详细的操作步骤. (1)修改配置文件my.cnf,在配置文件[mysqld]下添加skip-g ...

  3. windows下忘记mysql的root密码解决方法(图文)

    在windows下忘记mysql的root密码对于很对新手来说,也是会经常遇到的,我也刚好遇到啦,参考网上的解决办法,自己又整理啦一下. 1.首先需要查看mysql的服务是否启动. 打开cmd窗口,输 ...

  4. Linux忘记mysql的root密码的解决办法

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

  5. CentOS下设置MySQL的root密码

    CentOS刚装的MySQL一般需要重设MySQL密码,可以用以下方法重设. 方法一. Js代码  # /etc/init.d/mysqld stop  # mysqld_safe --user=my ...

  6. linux下忘记mysql的root密码

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

  7. Mac下忘记mysql的root密码

    cd /usr/local/mysql/bin sudo su sudo /usr/local/mysql/support-files/mysql.server stop # ./mysqld_saf ...

  8. CentOS7忘记mysql的root密码_处理方法.

    1.打开mysql的配置文件: vi /etc/my.cnf 2.在配置文件中添加:skip-grant-tables,然后保存退出, vi常用命令在最后.   如图 3.重启mysql servic ...

  9. linux下误删mysql的root用户,解决方法

    开始对liunx界面不熟悉,可能由于不小心,把root误删了,怎么办? 1. # killall mysqld    干掉所有mysql进程 2. # mysqld_safe --skip-grant ...

随机推荐

  1. delete archivelog all 无法彻底删除归档日志?

    最近在因归档日志暴增,使用delete archivelog all貌似无法清除所有的归档日志,到底是什么原因呢? 1.演示环境 SQL> select * from v$version whe ...

  2. library cache lock和cursor: pin S wait on X等待

    1.现象: 客户10.2.0.4 RAC环境,出现大量的library cache lock和cursor: pin S wait on X等待,经分析是由于统计信息收集僵死导致的.数据库在8点到9点 ...

  3. ViewPager 滑动页(四)

    需求:在ViewPager 滑动页(三) 基础上,减少界面层级. 效果图: 图层数变更前: 图层数变更后: 主要代码实现: <?xml version="1.0" encod ...

  4. XX.frame.origin.x 赋值问题

    can't use that myView.frame.origin.x=25.0; 因为.操作 和 = 一起用的话会调用 set方法.所以上式是行不通的. 可以用下面的方式来实现. that I h ...

  5. LR录制测试脚本

    1.录制的业务流程 2.录制脚本 3.查看脚本

  6. Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list_by_value(self, locator, *values)

    def select_from_list_by_value(self, locator, *values): """Selects `*values` from list ...

  7. JavaScript 性能优化 --By Google V8 Team Manager

    原文:https://developers.google.com/v8/?hl=zh-CN Be Prepared before writing code[9:35] Understand how V ...

  8. Java 8新特性之集合

    import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; i ...

  9. MATLAB Coder从MATLAB生成C/C++代码步骤

    MATLAB Coder可以从MATLAB代码生成独立的.可读性强.可移植的C/C++代码. 使用MATLAB Coder产生代码的3个步骤: 准备用于产生代码的MATLAB算法: 检查MATLAB代 ...

  10. yum 安装 php5.6 和 mysql5.6

    安装 PHP rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm; rpm - ...