mysql forget root password
http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password
MySQL - Resetting a lost MySQL root password
The MySQL root password allows full access to the MySQL database and allows for all actions to be undertaken including creating new users, new databases, setting access rules and so on.
Losing one can be a difficult issue to encounter. Luckily, resetting the root password is easy as long as you have sudo access to the Server.
Contents
Not the Server root user
A common issue is confusing the Server root user with the MySQL root user.
The Server root user is the server's main user. The MySQL root user has complete control over MySQL only. The two 'root' users are not connected in any way.
Stop MySQL
The first thing to do is stop MySQL. If you are using Ubuntu or Debian the command is as follows:
sudo /etc/init.d/mysql stop
For CentOS, Fedora, and RHEL the command is:
sudo /etc/init.d/mysqld stop
Safe mode
Next we need to start MySQL in safe mode - that is to say, we will start MySQL but skip the user privileges table. Again, note that you will need to have sudo access for these commands so you don't need to worry about any user being able to reset the MySQL root password:
sudo mysqld_safe --skip-grant-tables &
Note: The ampersand (&) at the end of the command is required.
Login
All we need to do now is to log into MySQL and set the password.
mysql -u root
Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.
Next, instruct MySQL which database to use:
use mysql;
Reset Password
Enter the new password for the root user as follows:
update user set password=PASSWORD("mynewpassword") where User='root';
and finally, flush the privileges:
flush privileges;
Restart
Now the password has been reset, we need to restart MySQL by logging out:
quit
and simply stopping and starting MySQL.
On Ubuntu and Debian:
sudo /etc/init.d/mysql stop
...
sudo /etc/init.d/mysql start
On CentOS and Fedora and RHEL:
sudo /etc/init.d/mysqld stop
...
sudo /etc/init.d/mysql start
Login
Test the new password by logging in:
mysql -u root -p You will be prompted for your new password.
mysql forget root password的更多相关文章
- windows下新安装的mysql修改root password问题
常用步骤: 1. 在my.ini中的mysqld下添加一行 skip-grant-tables 2.重启mysql后直接进入后,用SQL直接修改password列: C:\> net stop ...
- MYSQL更改root password时遇到Access Denied的解决办法
今天在公司虚拟机上装MYSQL之后需要修改root password,然而遇到这样的错误: Access denied for user 'root'@'localhost' (using passw ...
- mac 安装mysql + 修改root用户密码 + 及报Access denied for user 'root'@'localhost' (using password:YES)解决办法
1.下载MySQL 到mysql的官网http://dev.mysql.com/downloads/mysql/然后在页面中会看到“MySQL Community Server”下方有一个“downl ...
- Mysql修改root用户密码 For Mac 报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
环境 Mysql版本:5.7.12 操作系统:OSX 10.11 安装文件:.dmg文件 MySQL:mysql-5.7.12-osx10.11-x86_64.dmg(注意5.7跟之前的字段有些不同, ...
- Linux - Reset a MySQL root password
Use the following steps to reset a MySQL root password by using the command line interface. Stop the ...
- MySQL使用root用户授权出现错误ERROR 1045 (28000) at line 2: Access denied for user 'root'@'%' (using password: YES)解决办法
参考:https://blog.csdn.net/open_data/article/details/42873827 使用MySQL的root用户登录出现错误提示 ERROR 1045 (28000 ...
- MYSQL安装时解决要输入current root password的解决方法
在装MYSQL的时候发现要输入current root password不记得以前在电脑里装过(你的系统曾经装过MYSQL在重装就会要求输入原来设定的密码,如果是第一次安装就不会出现),在网上苦苦搜寻 ...
- Mysql安装配置以及解决重装Mysql时忘记root password问题
目录 1.Mysql安装以及环境变量配置 重装Mysql时忘记root password问题 1.Mysql安装以及环境变量配置 官网安装:https://www.mysql.com/ 按 ...
- mysql root password
"""centos:mysql忘记root密码解决 1.修改MySQL的登录设置: # vim /etc/my.cnf 在[mysqld]的段中加上一句:skip-gra ...
随机推荐
- 用canvas 实现个图片三角化(LOW POLY)效果
之前无意中看到Ovilia 用threejs做了个LOW POLY,也就是图片平面三角化的效果,觉得很惊艳,然后就自己花了点时间尝试了一下. 我是没怎么用过threejs,所以就直接用canvas的2 ...
- 用nhibernate的几点小经验
最近几个月都在用nhibernate做项目.写几点经验. 1. 解决Transient object exception 原项目是用Entity Framework做的.现在是用nhibernate代 ...
- Android开发自学笔记(Android Studio1.3.1)—1.环境搭建
一.引言 .Google推出的 毫无疑问,这个是它的最大优势,Android Stuido是Google推出,专门为Android"量身订做"的,是Google大力支持的一款基于I ...
- linux 防火墙开放特定端口与指定ip谨防
vi etc/iptable/sysconfig/iptables linux 开放固定端口 -A INPUT -m state --state NEW -m tcp -p tcp --dport 1 ...
- Rest API 开发 学习笔记(转)
Rest API 开发 学习笔记 概述 REST 从资源的角度来观察整个网络,分布在各处的资源由URI确定,而客户端的应用通过URI来获取资源的表示方式.获得这些表徵致使这些应用程序转变了其状态.随着 ...
- 使用D3制作图表(1)--画布绘制
使用D3绘制图表可以使数据更加直观. 使用D3前要先加载D3库,这里有两种方式,一种是在线加载<script type="text/javascript" src=" ...
- 解决Eclipse项目图标上的红色感叹号,红叉
从外部导入了几个jar包发现工程上出现红叉,但展开又没有详细的指明任何错误,可能过如下几步: 1.检查Build Path中的各个依赖jar及library是否有warning的标志,若有,处理之: ...
- springmvc中实现quartz定时任务
1.maven项目添加如下两个jar包,当然也需要相应的spring 的Jar <!-- Spring Quartz定时器 begin --> <dependency> < ...
- 【COGS 254】【POI 2001】交通网络图
http://www.cogs.top/cogs/problem/problem.php?pid=254 dist[i]表示能最早到达i点的时间.这样就可以用最短路模型来转移了. #include&l ...
- nginx.conf的events,http段一般固定配置
nginx.conf的events,http段一般固定配置 user nobody nobody; #使用的用户可以按照实际情况修改 worker_processes ; #指定nginx开启的进程数 ...