Use the following steps to reset a MySQL root password by using the command line interface.

Stop the MySQL service

(Ubuntu and Debian) Run the following command:

sudo /etc/init.d/mysql stop

(CentOS, Fedora, and Red Hat Enterprise Linux) Run the following command:

sudo /etc/init.d/mysqld stop

Start MySQL without a password

Run the following command. The ampersand (&) at the end of the command is required.

sudo mysqld_safe --skip-grant-tables &

Connect to MySQL

Run the following command:

mysql -uroot

Set a new MySQL root password

Run the following command:

use mysql;

update user set password=PASSWORD("mynewpassword") where User='root';

flush privileges;

quit

Stop and start the MySQL service

(Ubuntu and Debian) Run the following commands:

sudo /etc/init.d/mysql stop
...
sudo /etc/init.d/mysql start

(CentOS, Fedora, and Red Hat Enterprise Linux) Run the following commands:

sudo /etc/init.d/mysqld stop
...
sudo /etc/init.d/mysqld start

Log in to the database

Test the new password by logging in to the database.

mysql -u root -p

You are prompted for your new password.

Linux - Reset a MySQL root password的更多相关文章

  1. linux开机出现Give root password for maintenance (or type Control-D to continue):解决办法

    修改rc.local后导致 linux开机出现Give root password for maintenance,而且很多系统文件无法修改,之前的rc.local也不能修改了,单用户模式也无法进入 ...

  2. 运维笔记--linux下忘记mysql root密码

    补充链接:Windows下忘记密码处理: https://www.cnblogs.com/hellojesson/p/5972950.html 场景描述: Linux环境下忘记 root 密码, 1. ...

  3. mysql root password

    """centos:mysql忘记root密码解决 1.修改MySQL的登录设置: # vim /etc/my.cnf 在[mysqld]的段中加上一句:skip-gra ...

  4. linux下忘记mysql root密码解决办法

    vi /etc/my.cnf    #编辑文件,找到[mysqld],在下面添加一行skip-grant-tables [mysqld] skip-grant-tables :wq!  #保存退出 s ...

  5. Linux下修改mysql root密码

    1.修改MySQL的配置文件(默认为/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables 2.保存配置文件后,重启MySQL服务 service mysqld re ...

  6. linux 下解决mysql root 权限无法远程连接问题

    问题描述:MySQL数据库安装成功后,在服务器本地可以连接成功,但是使用工具navicat无法进行远程连接,如图: 原因:MySQL默认只允许root帐户在本地登录,如果要在其它机器上连接mysql, ...

  7. mysql forget root password

    http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password MySQL - ...

  8. linux 安装完mysql 密码重置

    If you have forgot the MySQL root password, can’t remember or want to break in….. you can reset them ...

  9. Give root password for maintenance

    linux开机出现"Give root password for maintenance (or type Control-D to continue):" 出现这种情况一般为两种 ...

随机推荐

  1. Java添加自定义注解

    今天在整合MyBatis过程中,我使用扫描的方式去扫描DAO目录下的Java文件,但是在Service层使用Autowired的时候报错,但是工程能正常运行,此处有Bug! 解决方案: 1.创建 an ...

  2. 来,试试PERL

    试试,看看能否真的替代AWK,SED这些的... #!/usr/bin/perl print "hello, world!\n"; $line = <STDIN>; i ...

  3. scheme 解释器Guile 使用

    GNU Guile是一种Scheme编程语言的解释器和虚拟机.Guile是GNU Ubiquitous Intelligent Language for Extensions的缩写.Guile是GNU ...

  4. logstash match

    [elk@zjtest7-frontend config]$ cat stdin04.conf input { stdin { } } filter { # drop sleep events gro ...

  5. win7系统如何恢复administrator用户

    默认情况下,administrator用户是禁用的. 要恢复的话,右键单击我的电脑 管理-->本地用户和组-->用户-->右键属性 把"账户已禁用"前的选择符号去 ...

  6. RequireJS入门(二)

    上一篇是把整个jQuery库作为一个模块.这篇来写一个自己的模块:选择器. 为演示方便这里仅实现常用的三种选择器id,className,attribute.RequireJS使用define来定义模 ...

  7. (转)iOS7界面设计规范(6) - UI基础 - 模态情境

    继续规范.现在听着Clapton的Wonderful Tonight,想想看,整个高二暑假都在为这首歌着迷,经常夜里一边做英语暑期作业一边循环这首歌,心里特别静的赶脚.13年过去了,再听起来,就像隔着 ...

  8. ffmpeg + sdl -03 简单音频播放器实现

    没办法,工作中遇到了问题. 目前NEC EMMA的架构如下: 从USB读入文件 -> 文件分析并提取Packet中的Payload Data   -> NEC HANDLE AVTrans ...

  9. LoadRunner测试下载功能点脚本(方法二)

    在上一篇<LoadRunner下载功能点脚本(方法一)>中,实现的脚本仅是录制下载功能点的脚本,现在性能需求的场景更改如下: 性能需求:对系统某页面中,点击下载并将下载文件保存到本地电脑的 ...

  10. 使用Dataset

    string sqlStr="Select * from Tb_news"; SqlDataAdapter myDa=new SqlDataAdapter(SqlStr,myCon ...