Development Tip

루트 비밀번호를 null로 설정하는 방법

yourdevel 2020. 11. 25. 21:16
반응형

루트 비밀번호를 null로 설정하는 방법


rootMySQL 사용자의 암호 null-암호 없음 또는 ''-MySQL 명령 줄 클라이언트에서 어떻게 변경할 수 있습니까?


다음 5 가지 간단한 단계를 통해 MySQL 데이터베이스 서버 비밀번호를 복구 할 수 있습니다.

1 단계 : MySQL 서버 프로세스를 중지합니다.

2 단계 : --skip-grant-tables 옵션을 사용하여 MySQL (mysqld) 서버 / 데몬 프로세스를 시작하여 비밀번호를 묻는 메시지를 표시하지 않도록합니다.

3 단계 : 루트 사용자로 mysql 서버에 연결합니다.

4 단계 : 새 mysql 루트 계정 암호를 설정합니다. 즉, mysql 암호를 재설정합니다.

5 단계 : MySQL 서버를 종료하고 다시 시작합니다.

다음은 각 단계에 대해 입력해야하는 명령입니다 (루트 사용자로 로그인).

1 단계 : mysql 서비스 중지

# /etc/init.d/mysql stop

산출:

Stopping MySQL database server: mysqld.

2 단계 : 비밀번호없이 MySQL 서버 시작 :

# mysqld_safe --skip-grant-tables &

산출:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

3 단계 : mysql 클라이언트를 사용하여 mysql 서버에 연결합니다.

# mysql -u root

산출:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

4 단계 : 새 MySQL 루트 사용자 암호 설정

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

5 단계 : MySQL 서버 중지 :

# /etc/init.d/mysql stop

산출:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
[1]+  Done                    mysqld_safe --skip-grant-tables

6 단계 : MySQL 서버 시작 및 테스트

# /etc/init.d/mysql start
# mysql      
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 
# mysql -u root -p

출처 : http://www.cyberciti.biz/tips/recover-mysql-root-password.html


저와 "5.7.11 MySQL Community Server"를 위해 일했습니다.

use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';

'plugin'필드도 'auth_socket'으로 설정 되었기 때문에 변경해야했습니다.

그 후에 mysql -u root는 암호없이 연결할 수 있습니다 .


빈 암호를 원하면 암호를 null로 설정하고 다음과 같이 암호 해시 기능을 사용하지 않아야합니다.

명령 줄에서 :

sudo service mysql stop
sudo mysqld_safe --skip-grant-tables --skip-networking &
mysql -uroot

MySQL에서 :

use mysql;
update user set password=null where User='root';
flush privileges;
quit;

  • 사용자 루트로 mysql에 연결 (다음 두 가지 방법 중 하나 사용)
    • 루트로 로그인하고를 사용하여 mysql을 시작하고 mysql -p현재 루트 비밀번호를 입력하십시오.
    • 자신으로 로그인하고 사용하여 mysql을 시작하고 mysql -u root -p현재 루트 암호를 입력하십시오.
  • mysql> set password = password('');

끝난! 루트 암호가 없습니다.


SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');

이것은 v5.7.15 MySQL을 사용하는 Ubuntu 16.04에서 저에게 효과적이었습니다.

먼저 mysql-client가 설치되어 있는지 확인하십시오 ( sudo apt-get install mysql-client).

터미널 열기 및 로그인 :

mysql -uroot -p

(그런 다음 암호를 입력하십시오)

그 후 :

use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';

(tnx @Stanislav Karakhanov)

마지막으로 중요한 것은 mysql 서비스재설정하는 것입니다 .

sudo service mysql restart

이제 MySQL Workbench를 사용하여 (암호없이) 로그인 할 수 있습니다.


mysql데이터베이스를 직접 편집하는 것은 좋지 않습니다 .

다음 단계를 선호합니다.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY ''; 
mysql> flush privileges;

MySQL 8.0의 경우 :

SET PASSWORD FOR 'root'@'localhost' = '';


user64141의 답변

use mysql;
update user set password=null where User='root';
flush privileges;
quit;

MariaDB 10.1.5에서 작동하지 않았습니다 (MySQL을 대체하는 것으로 추정 됨). 업스트림 변경 여부를 확인하기 위해 MySQL 5.6에서 테스트하지는 않았지만 오류는 다음과 같습니다.

오류 1048 (23000) : 'Password'열은 null 일 수 없습니다.

그러나 null을 빈 작은 따옴표 또는 큰 따옴표로 바꾸면 정상적으로 작동했습니다.

update user set password='' where User='root';

또는

update user set password="" where User='root';

그것은 나를 위해 작동합니다.

ALTER USER 'root'@ 'localhost'IDENTIFIED with mysql_native_password by 'password'


이것은 MySQL 8.0.13에서 가져온 것입니다.

use mysql;

update user set authentication_string=null  where user='root';

quit;

루트 비밀번호를 알고 있고 재설정하려면 다음과 같이하십시오.

  • 제어판> 관리 도구> 서비스에서 MySQL 서비스를 시작합니다. (이전에 중지 한 경우에만! 그렇지 않으면이 단계를 건너 뛰십시오.)

  • MySQL Workbench 시작

  • 이 명령 / SQL 줄에 입력

    ALTER USER 'root'@ 'localhost'PASSWORD 만료;

To reset any other user password... just type other user name instead of root.


For connect to mysql without password:

mysql -p SET PASSWORD = ""

https://dev.mysql.com/doc/refman/5.7/en/set-password.html


I am using nodejs and windows 10. A combination of two answers worked for me.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY ''; 
mysql> flush privileges;

followed by:

restart;

Hope this helps for others who still have an issue with this.


The syntax is slightly different depending on version. From the docs here: https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

MySQL 5.7.6 and later:

ALTER USER 'root'@'localhost' IDENTIFIED BY '';

MySQL 5.7.5 and earlier:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');

My variant for MySQL 5.7:

Stop service mysql:

$ sudo service mysql stop

Running in Safe Mode:

$ sudo mysqld_safe --skip-grant-tables --skip-networking

(above line is the whole command)

Open a new terminal window:

$ mysql -u root

$ mysql use mysql;

$ mysql update user set authentication_string=password('password') where user='root';

$ mysql update user set plugin="mysql_native_password" where User='root';

$ mysql flush privileges;
$ mysql quit;

Run the mysql service:

$ sudo service mysql start

Wanted to put my own 2cents in here bcuz the above answers did not work for me. On centos 7, mysql community v8, shell is bash.

The correct commands would be as follows:

# start mysql without password checking
systemctl stop mysqld 2>/dev/null
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables" &&
systemctl start mysqld

# set default password to nothing
mysql -u root mysql <<- 'EOF'
    FLUSH PRIVILEGES;
    UNINSTALL COMPONENT 'file://component_validate_password';
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
    FLUSH PRIVILEGES;
    INSTALL COMPONENT 'file://component_validate_password';
EOF

# restart mysql normally
systemctl restart mysqld

then you can login without password:

mysql -u root

its all because you installed greater then 5.6 version of the mysql

Solutions

1.you can degrade mysql version solution

2 reconfigure authentication to native type or legacy type authentication using
configure option


I noticed a few of these solutions above are now deprecated.

To set an empty password simply follow these steps:

mysql -u root -p

use mysql

SET PASSWORD FOR 'root'@'localhost' = '';

\q (to quit)

now run: mysql -u root

You should be able to start mysql up without a password now.


After searching for hours i found it . just Change the password to something contains Upper case numeric and special characters in it.

참고URL : https://stackoverflow.com/questions/2101694/how-to-set-root-password-to-null

반응형