728x90
개요
MySQL의 root 유저의 패스워드를 모를 때 DB에 접속해서 패스워드를 변경해주는 방법
Solution
1) 해당 MySQL DB 다운
2) --skip-grant-tables 옵션을 주고 DB를 기동
# mysqld_safe --skip-grant-tables &
2024-05-23T05:25:29.857984Z mysqld_safe Logging to '/logs001/mysql/mysqld.log'.
2024-05-23T05:25:29.888917Z mysqld_safe Starting mysqld daemon with databases from /data001/mysql/master
3) 패스워드 없이 root 접속 후 패스워드 변경
# mysql -u root
mysql> use mysql;
mysql> update user set authentication_string=null where user='root';
mysql> flush privileges;
4) DB kill
[root@localhost ibdata]# ps -ef | grep mysql
mysvc01 349003 348961 0 14:25 pts/1 00:00:00 /bin/sh /engn001/mysql/bin/mysqld_safe --skip-grant-tables
mysvc01 349967 349003 0 14:37 pts/1 00:00:01 /engn001/mysql/bin/mysqld --basedir=/engn001/mysql --datadir=/data001/mysql/master --plugin-dir=/engn001/mysql-commercial-8.0.36-linux-glibc2.28-x86_64/lib/plugin --skip-grant-tables --log-error=/logs001/mysql/mysqld.log --pid-file=/data001/mysql/mysqld.pid --socket=/data001/mysql/mysql.sock --port=3306
root 350132 245109 0 14:41 pts/2 00:00:00 grep --color=auto mysql
-- mysqld_safe 명령 kill
[root@localhost ibdata]# kill -9 349003
-- DB kill
[root@localhost ibdata]# kill -9 349967
5) DB 기동
# systemctl start mysql
6) 정상 접속 확인
# mysql -u root
mysql> alter user 'root'@'localhost' identified with caching_sha2_password by '새로 설정할 비밀번호';
728x90
'📁 Database > MySQL & MariaDB' 카테고리의 다른 글
[MySQL] MYSQLD_OPT 에 대해 (0) | 2024.05.27 |
---|---|
[MySQL] mysqld와 mysqld_safe의 차이 (0) | 2024.05.27 |
[MySQL] mysqld: Can't open shared library (0) | 2024.05.23 |
[MariaDB] Centos 7, MariaDB 10.6 설치 - 인터넷 안되는 환경, 수동설치, rpm 설치 (0) | 2024.03.26 |
[MariaDB] MariaDB 설치 중 에러 (0) | 2024.03.26 |