'root비밀번호변경'에 해당되는 글 1건

리눅스 mysql root 비밀번호 변경 및 분실시 초기화

 

 

mysqladmin 을 이용한 mysql 비밀번호 변경 방법이다.

 

# mysqladmin -u root -p password

Enter password:

New password:

Confirm new password:

순서대로 기존암호, 변경암호, 확인암호

 

 

 


 

 

이번엔 분실시 초기화에 대해서 알아보자.

CentOS 7.x 버전에는 mariadb 이다. 그래서 6.x 버전과는 좀 다르다.

 

# systemctl stop mariadb.service

먼저 위의 명령어로 mariadb 서비스를 종료하자.

 

다음엔 아래의 굵은 글씨를 참고해서 변경해주면 된다.

[root@conoha ~]# mysqld_safe --skip-grant-tables --skip-networking &

[1] 14248

[root@conoha ~]# 160406 13:43:10 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.

160406 13:43:10 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

 

[root@conoha ~]# mysql -u root

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 1

Server version: 5.5.44-MariaDB MariaDB Server

 

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

MariaDB [mysql]> update user set password=PASSWORD('1234') where User='root';

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4  Changed: 4  Warnings: 0

 

MariaDB [mysql]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [mysql]> quit

Bye

[root@conoha ~]#

 

 

여기까지 완료했다면 mysql 재시작

# systemctl start mariadb.service

 

이제 사용하면 된다.

 

블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,