MySQL - 루트 비밀번호를 잊어버린 경우 작동 방법

黄舟
풀어 주다: 2017-01-21 13:26:06
원래의
1356명이 탐색했습니다.

1. 명령줄에

root@centos64 mysql]# /usr/bin/mysqld_safe --skip-grant-tables&
로그인 후 복사

명령을 입력합니다. 2. 터미널을 시작하고 다음 명령을 실행합니다.

[root@centos64 proc]# mysql  
Welcome to the MySQL monitor.  Commands end with ; or \g.  
Your MySQL connection id is 1  
Server version: 5.6.13 MySQL Community Server (GPL)  
  
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.  
  
Oracle is a registered trademark of Oracle Corporation and/or its  
affiliates. Other names may be trademarks of their respective  
owners.  
  
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  
mysql> UPDATE user SET password=password('admin') WHERE user='root';  
ERROR 1046 (3D000): No database selected  
mysql> show databases ;  
+--------------------+  
| Database           |  
+--------------------+  
| information_schema |  
| mysql              |  
| performance_schema |  
| test               |  
+--------------------+  
4 rows in set (0.06 sec)  
  
mysql> 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  
mysql> UPDATE user SET password=password('admin') WHERE user='root';  
Query OK, 4 rows affected (0.04 sec)  
Rows matched: 4  Changed: 4  Warnings: 0  
  
mysql> flush privileges;   也可以不用。  
  
mysql> exit  
Bye
로그인 후 복사

사용자 테이블에 사용자 테이블이 없습니다. 루트 사용자가 없습니다.
해당 사용자가 없으면

mysql> insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values("localhost","root",password("admin"),"","","");  
Query OK, 1 row affected (0.10 sec)
로그인 후 복사

를 사용하세요.3. 모든 권한을

mysql> grant all privileges on *.* to  'root'@'localhost' identified by 'admin' ;  
Query OK, 0 rows affected (0.06 sec)  
mysql> flush privileges;
로그인 후 복사

부여한 다음 정상적으로 시작하세요.

위는 MySQL의 내용입니다. Root 비밀번호를 잊어버린 경우의 조작방법에 대한 자세한 내용은 PHP 중국어 홈페이지(www.php.cn)를 참고해주세요!


관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!