Mysql 5.7 루트 비밀번호 잊 고 mysql 5.7 루트 비밀번호 수정 방법

실행 중인 MySQL 닫 기:

[[email protected] ~]# service mysql stop
운행 하 다.

[[email protected] ~]# mysqld_safe --skip-grant-tables &
안전 을 위해 원 격 연결 을 금지 할 수 있 습 니 다:

[[email protected] ~]# mysqld_safe --skip-grant-tables --skip-networking &
mysql 로 server 연결 하기:

[[email protected] ~]# mysql -p
비밀번호 변경:

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
*특히 주의해 야 할 점 은 새 my sql 데이터베이스 에 있 는 user 표 에 Password 필드 가 없습니다.
암호 화 된 사용자 암 호 를 authentication 에 저장 합 니 다.string 필드

mysql> flush privileges;
mysql> quit;
수정 완료.다시 시작

[root@localhost ~]# service mysql restart
그리고 mysql 로 연결 할 수 있어 요.
하지만 이 때 는 기능 이 불완전 한 것 같 습 니 다.alter user...

mysql> alter user 'root'@'localhost' identified by '123';
이렇게 해도 된다.

mysql> set password for 'root'@'localhost'=password('123');
my sql 5.7 root 비밀번호 수정 에 중점 을 두 겠 습 니 다.
MySQL 관리자 비밀번호 설정 또는 변경:
공식 설명 5.6 이후 버 전 에 따 르 면 첫 번 째 시작 시 루트 디 렉 터 리 에서 무 작위 비밀 번 호 를 생산 합 니 다.파일 이름.my sqlsecret。

[root@bright ~]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2015-03-27 23:12:10
:Jj+FTiqvyrF
[root@bright ~]# cd /usr/local/mysql/bin/
[root@bright bin]# ./mysqladmin -u root -h localhost password '123456' -p
비밀번호 입력:\#이 줄 에.mysql 입력비밀 속 두 번 째 줄 내용

mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
공식 적 인 방식 으로 필 자 는 사용 여부-skip-grant-tables 시작 my sql 에 실 패 했 습 니 다.여러분 은 테스트 할 수 있 습 니 다.

shell>mysql -uroot -p'password' #password .mysql_secret    
mysql>SET PASSWORD = PASSWORD('newpasswd');

이전 버 전,설치 후 ROOT 에 비밀번호 가 없습니다.다음 을 누 르 십시오.
방법 1:

shell>service mysqld stop #  mysql  
shell>mysqld_safe --skip-grant-tables & #    grant-tables    mysql
shell>mysql -uroot -p #        ,            。
mysql>use mysql;
mysql>update user set password=PASSWORD("123456")where user="root"; #      newpassord
mysql>flush privileges; #    
mysql>quit #  
방법 2:

shell>service mysqld stop #  mysql  
shell>mysqld_safe --skip-grant-tables & #    grant-tables    mysql
shell>mysql -uroot -p #        ,            。
mysql > set password for root@localhost = password('mysqlroot');
방법 3:

shell>/path/mysqladmin -u UserName -h Host password 'new_password' -p

좋은 웹페이지 즐겨찾기