[mysql] root 패스워드 찾기

[mysql] root 패스워드 찾기 updated_at: 2024-03-20 12:16

root 패스워드 찾기

1. mysql 프로세스를 모두 죽인다.

[root@onstory bin]# killall mysqld

2. mysql 데몬 띄우기

[root@onstory bin]# ./mysqld_safe --skip-grant-tables
Starting mysqld daemon with databases from /usr/local/mysql5/var

3. 루트로 로긴

[root@onstory bin]# ./mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.22-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

4. mysql db로 접근

mysql> use mysql
Database changed

5. 루트패스워드변경

mysql> update user set password = password('**************') where user = 'root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

6. mysql 빠져나옮

mysql> quit
Bye

7. mysql 프로세스를 모두 죽인다.

[root@onstory bin]# killall mysqld

8. mysql 재시작

[root@onstory bin]# ./mysqld_safe &
[2] 519
[root@onstory bin]# Starting mysqld daemon with databases from /usr/local/mysql5/var

요약설명

[root@ns root]# // 루트로 접속한다. 
[root@ns root]# /etc/rc.d/rc3.d/./S90mysqld stop // mysql 프로세스를 죽인다. 
[root@ns root]# /usr/local/mysql/bin/./safe_mysqld --skip-grant-tables& // 임시모드로 mysql 실행 
[root@ns root]# mysql // mysql 접속 
mysql> use mysql; 
mysql> update user set password=password('newpw') where user = 'root'; // 루트 암호를 변경한다. 
mysql> \q 
[root@ns root]# /usr/local/mysql/bin/./safe_mysqld& // mysql 재실행 
평점을 남겨주세요
평점 : 5.0
총 투표수 : 1