转 Resetting the root password for MySQL

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

Resetting the root password for MySQL running on RHEL or CentOS

06Sep

I recently had to reset the MySQL root password due to the fact that initializing it the way I assumed it should did not work. The following procedure will work in CentOS/RHEL/Scientific Linux and Fedora.

After installing MySQL using

# yum install mysql-server

I ran the command

# mysqladmin -u root password 'new-password'

Trying to log in with the following failed

# mysql -u root -p

with the following error

Access denied for user 'root'@'localhost'

Decided to not spend more time as it’s a fresh MySQL installation. And did the following to reset the root password for MySQL.

Resetting the root password

1) Stopped the MySQL service.

# service mysqld stop

2) Started MySQL in safe mode.

# mysqld_safe --skip-grant-tables &

3) Logged in using root.

# mysql -u root

4) Reset the password.

> use mysql;
> update user set password=PASSWORD("mynewpassword") where User='root';
> flush privileges;
> quit

5) Stop MySQL in safe mode.

# service mysqld stop

6) Start MySQL.

# service mysqld start

7) Log in using the new password.

# mysql -u root -p

Success!

// CrashMAG


原文地址:http://crashmag.net/resetting-the-root-password-for-mysql-running-on-rhel-or-centos

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
缓存 关系型数据库 MySQL
MySQL登录时出现Access denied for user ‘root‘@‘localhost‘ (using password: YES)无法打开的解决方法
MySQL登录时出现Access denied for user ‘root‘@‘localhost‘ (using password: YES)无法打开的解决方法
|
8月前
|
关系型数据库 MySQL Linux
Linux登录mysql忘记密码Access denied for user ‘root‘@‘localhost‘ (using password: YES)错误
Linux登录mysql忘记密码Access denied for user ‘root‘@‘localhost‘ (using password: YES)错误
76 0
|
4月前
|
Ubuntu 关系型数据库 MySQL
Mysql Access denied for user ‘root‘@ ‘*.*.*.*‘ (using password: YES)异常处理
Mysql Access denied for user ‘root‘@ ‘*.*.*.*‘ (using password: YES)异常处理
49 0
Mysql Access denied for user ‘root‘@ ‘*.*.*.*‘ (using password: YES)异常处理
|
6月前
|
SQL 网络协议 关系型数据库
【MySQL用法】在MySQL登录时出现Access denied for user ‘root‘@‘localhost‘ (using password: YES) 拒绝访问,并可修改MySQL密码
【MySQL用法】在MySQL登录时出现Access denied for user ‘root‘@‘localhost‘ (using password: YES) 拒绝访问,并可修改MySQL密码
113 1
|
9月前
|
XML 关系型数据库 MySQL
已解决Failed to connect mysql database,please check username and password,or mysql is version8? true
已解决Failed to connect mysql database,please check username and password,or mysql is version8? true
115 0
|
10月前
|
关系型数据库 MySQL 数据安全/隐私保护
mysql解决:当你要重置密码时报错Your password does not satisfy the current policy requirements
mysql解决:当你要重置密码时报错Your password does not satisfy the current policy requirements
|
10月前
|
关系型数据库 MySQL Linux
忘记密码 mysql forge root password
忘记密码 mysql forge root password
84 0
|
10月前
|
关系型数据库 MySQL 数据安全/隐私保护
一文极速解决Navicat或者MySQL报错:1045-Access denied for user root@localhost(using password:YES)
一文极速解决Navicat或者MySQL报错:1045-Access denied for user root@localhost(using password:YES)
484 0
|
10月前
|
关系型数据库 MySQL 数据安全/隐私保护
关于MySQL8.0移除PASSWORD()函数
关于MySQL8.0移除PASSWORD()函数
|
11月前
|
关系型数据库 MySQL 数据安全/隐私保护

推荐镜像

更多