메뉴 닫기

mysql 패스워드 변경

 

mysqld 중지

[root@localhost ~]# service mysqld stop

mysqld_safe 실행

[root@localhost ~]# /usr/bin/mysqld_safe --skip-grant &
[1] 32055
Starting mysqld daemon with databases from /var/lib/mysql

새 패스워드 지정

mysql 콘솔로 들어간후

/usr/bin/mysql -uroot mysql

다음 SQL 명령어를 입력하여 원하는 패스워드로 변경합니다.

update user set password=password('패스워드') where user='root'; 
flush privileges; 
quit

실행 ex)
[root@localhost ~]# /usr/bin/mysql -uroot mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> update user set password=password('Password') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit
Bye

mysqld 재시작

이제 패스워드를 입력해야만 mysql을 사용할 수 있도록 하기 위해, mysqld를 재시작합니다.

[root@localhost ~]# service mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
120229 13:08:54  mysqld ended
 
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]
[1]+  Done                    /usr/bin/mysqld_safe --skip-grant 라고 뜹니다.

끝!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x