Resetting MySQL Root Password on CentOS

It is not uncommon for you to need the MySQL root password of a server, especially when you’re dealing with hundreds of different servers. Here’s the quickest way to reset it. (Don’t forget that you need to login to your server as root in order to achieve this)

1) Start MySQL in safe mode.

2) Reset the root password.

3) Flush privileges.

4) Create a my.cnf file so that you can automatically log-in next time.
# service mysqld stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
> update mysql.user set password=PASSWORD("newpass") where User='root';
> flush privileges;
> exit;
# { echo "[client]"; echo "user=root"; echo "password=newpass"; } >> /root/.my.conf
# service mysqld restart
  • 96 用戶發現這個有用
這篇文章有幫助嗎?

相關文章

Setting time with NTP in LINUX

NTP (Network Time Protocol) could be used to set time synced with ntp clocks, to do this use the...

Linux version & Operating System info

LINUX Version Info To learn the architecture and kernel version info use the shell command...

Compile and build Apache + MySQL + PHP from the source [cite]

This is a complete working solution to build Apache (httpd-2.2.25), MySQL (MySQL-5.6.14) and PHP...

Using vi Editor

Vi is the one of the mostly used editor in Linux via terminal. In most cases where Linux is used...

Build PHP5.5 on CentOS 6.4 with MSSQL Support [cite]

Most of the yum repos doesn’t include PHP5.5.X on current releases for the time being. So...