> 데이터 베이스 > MySQL 튜토리얼 > [转载]MySQL: Reset Lost Root Password_MySQL

[转载]MySQL: Reset Lost Root Password_MySQL

WBOY
풀어 주다: 2016-06-01 13:48:54
원래의
1546명이 탐색했습니다.

bitsCN.com

Here is a quick Step-by-Step “how to” which helps restoring MySQL root password that was lost/forgotten.

It happens to everybody, especially if several distributed (different) systems are maintained, where the password is not the same. Here is what needs to be done to restore it:

Step 1: Stop MySQL daemon if it is currently running

Depending on the operating system MySQL is installed on, the daemon can be checked/stopped differently. Here is an example on how to do it in Unix-like systems.

[ NOTE ]: You might need to run it as a Unix System superuser (root) - depending on           how the system is configured, and what permissions your Unix account is granted)
로그인 후 복사

Here is how to stop/kill the existing mysql daemon, in case it is running:

      ps -ef | grep mysql      - checks if mysql/mysqld is one of the running processes.       pkill mysqld             - kills the daemon, if it is running.
로그인 후 복사

Note: if pkill (’process kill’) is not on a particular Unix system, use kill -9 ‘pid’, where ‘pid’ corresponds to processes that were found with ps -ef | grep mysql

Step 2: Run MySQL safe daemon with skipping grant tables

      mysqld_safe --skip-grant-tables &
로그인 후 복사

Step 3: Login to MySQL as root with no password

      mysql -u root mysql
로그인 후 복사

Step 4: Run UPDATE query to reset the root password

In MySQL command line prompt issue the following two commands:

      UPDATE user SET password=PASSWORD("ualue=42") WHERE user="root";      FLUSH PRIVILEGES;
로그인 후 복사

“ualue=42” is a common password for “The Hitchhiker’s Guide to the Galaxy” people which reads “Ultimate Answer to Life, the Universe, and Everything=42“

Step 5: Stop MySQL safe daemon

Follow the first two steps, but this time kill (pkill) “mysqld_safe” instead of “mysqld”

Step 6: Start MySQL daemon

Depending on the operating system (Unix-like examples):

      /etc/rc.d/rc.mysql start
로그인 후 복사

OR

      /etc/init.d/mysql start
로그인 후 복사

OR

      /etc/rc.5/mysql start
로그인 후 복사

etc.. check existing MySQL configuration

Step 7: Root password is reset and ready to use

Password is reset. Privileges are flushed. Start MySQL and login as root with the password set in step 4:

      mysql -u root -p mysql
로그인 후 복사

Note: sometimes (most of the time) ‘root user’ privileges are required for the system (OS) in order to stop/start processes

这里是原文链接

bitsCN.com
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿