programing

어떻게 CentOS7에 MySQL루트 계정 비밀 번호를 바꾸도록?

goodsources 2022. 9. 8. 22:50
반응형

어떻게 CentOS7에 MySQL루트 계정 비밀 번호를 바꾸도록?

Centos7 vm mySQㄹㄹㄹㄹㄹㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴ내가 암호 없이는 벌목 또는(mysql처럼, 관리 등)나는my.cnf 파일에 없고 암호가 보였다 어떤 기본 사람들도 시도했었죠.하고 다시 를 변경해 보았습니다.mysqld_safe --skip-grant-tables & 이해는 해냈다.mysqld_safe:command not found나는 알 수 없는 다른 할 일.힌트 / 힌트 / 힌트

mySQL 버전 어떻게 당신이 사용하고 있는?나는 "m에 루트로서 로그인과 같은 문제로 고민했어 5.7.10을 사용하여.

거기에는 2문제-뿌리 식물이라고, 왜 저는 그렇게 못하는 로그에서 시작하기 전에, 저는 왜 그 루트 비밀 번호 초기화를 신청 mySQL 시작할 'mysqld_safe`를 사용할 수 없다.

지만, 당신은 루트 비밀 번호 초기화를 신청하는데 설치 중에 루트 비밀 번호를 설정하고 해답을 모르겠어요.

편집 설치에 들인 초기 루트 비밀 번호를 가동하여 발견할 수 있다.

grep 'temporary password' /var/log/mysqld.log

http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html


  1. systemd mySQL이 하는 데 됩니다.mysqld_safe ' 하다.-bash: mysqld_safe: command not founderror -installed) (되어 있지 않습니다)

  2. user이치노

을 mySQ로 시작합니다.ㄹㄹㄹㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴㄴ.--skip-grant-tables 및 " " " " 。user테이블이 바뀌었습니다.

1. Stop mysql:
sudo systemctl stop mysqld

2. Set the mySQL environment option 
sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set
sudo systemctl start mysqld

4. Login as root
mysql -u root

5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword')
    -> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

*** Edit ***
As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
   mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Or you'll get a warning

6. Stop mysql
sudo systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time
sudo systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:
sudo systemctl start mysqld

Try to login using your new password:
7. mysql -u root -p

언급

http://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html,에 기재되어 있는 바와 같이

메모

MySQL 5.7.6에서는 RPM 디스트리뷰션을 사용한 MySQL 설치의 경우 서버 시작 및 종료는 여러 Linux 플랫폼에서 systemd에 의해 관리되고 있습니다.이러한 플랫폼에서는 mysqld_safe는 불필요하기 때문에 설치되지 않습니다.자세한 내용은 섹션 2.5.10 "Systemd를 사용한 MySQL Server 관리"를 참조하십시오.

http://dev.mysql.com/doc/refman/5.7/en/server-management-using-systemd.html에 접속하여systemctl set-environment MYSQLD_OPTS=페이지 하부에 표시됩니다.

password reset 명령어는 http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html의 하단에 있습니다.

위의 Kevin Jones의 조언에 따라 보안을 약간 강화하기 위해 다음과 같은 네트워크 변경 사항을 생략했습니다.

sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --skip-networking"

[user@machine ~]$ mysql -u root

그 후 패스워드를 리셋하려고 했을 때 에러가 발생했지만, 다른 곳에서 검색하면 간단하게 조작할 수 있다고 생각됩니다.다음과 같은 작업이 수행되었습니다.

mysql> select user(), current_user();
+--------+-----------------------------------+
| user() | current_user()                    |
+--------+-----------------------------------+
| root@  | skip-grants user@skip-grants host |
+--------+-----------------------------------+
1 row in set (0.00 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'sup3rPw#'
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'sup3rPw#'
Query OK, 0 rows affected (0.08 sec)

mysql> exit
Bye
[user@machine ~]$ systemctl stop mysqld
[user@machine ~]$ sudo systemctl unset-environment MYSQLD_OPTS
[user@machine ~]$ systemctl start mysqld

그 시점에서 로그인을 할 수 있었습니다.

패스워드를 리셋 하려면 , 다음의 순서에 따릅니다.

$ sudo systemctl start mysqld

MySql 서버 루트 암호를 재설정합니다.

$sudo grep 'temporary password' /var/log/mysqld.log

출력은 다음과 같습니다.

 10.744785Z 1 [Note] A temporary password is generated for root@localhost: o!5y,oJGALQa

리셋 mysql_secure_install 프로세스에서는 위의 비밀번호를 사용합니다.

<pre>
    $ sudo mysql_secure_installation
</pre>
   Securing the MySQL server deployment.

   Enter password for user root: 

MySql Server의 루트 암호를 재설정했습니다.다음 명령을 사용하여 mysql 서버의 연결 여부를 확인합니다.

$ mysql -u root -p

http://gotechnies.com/install-latest-mysql-5-7-rhelcentos-7/

센트의 경우OS 7과 MariaDB 10.4에서는 다음 명령어를 사용하여 성공하였습니다.

su -
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --user=mysql"
systemctl restart mariadb
mysql -u root

flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
flush privileges;
quit

systemctl unset-environment MYSQLD_OPTS
systemctl restart mariadb

모든.

mysql-community-server 5.7에서는 mysql5.7 루트 패스워드를 리셋하거나 패스워드를 설정하는 방법에 대해 설명합니다.centos7과 RHEL7도 동작합니다.

1단계. 데이터베이스를 중지합니다.

service mysqld stop

스텝 2. 변경/etc/my.cnffile add "syslog-syslog"

vi /etc/my.cnf
[mysqld]
skip-grant-tables

스텝 3. mysql을 시작합니다.

service mysqld start

스텝 4. mysql 기본 데이터베이스 선택

mysql -u root

mysql>use mysql;

스텝 4. 새로운 패스워드를 설정합니다.

mysql> update user set authentication_string=PASSWORD("yourpassword") where User='root';

5단계. 삭제skip-grant-tables부터/etc/my.cnf파일.

스텝 6. mysql 데이터베이스를 재시작합니다.

service mysqld restart

mysql -u root -p

즐기다:)

/etc/init.d/mysqld stop 명령을 사용하여 모든 MySQL 서비스를 중지하십시오.

mysqld_safe --mysqld_safe --mysqld-s

올바르게 동작할 수 있다

저는 이렇게 작업합니다: 1Stop mysql: systemctl stop mysqld

  1. mySQL 환경 옵션 systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"를 설정합니다.

  2. start mysql systemctl start mysqld 옵션을 사용합니다.

  3. root mysql -u root으로 로그인

  4. 로그인 후 FLUSH PRIVALYS를 사용합니다.계정관리문이 동작하도록 서버에 인가 테이블을 새로고침하도록 지시합니다.그렇지 않으면 비밀번호를 업데이트하려고 하면 "사용자 테이블에서 일치하는 행을 찾을 수 없습니다"라는 오류가 표시됩니다.

언급URL : https://stackoverflow.com/questions/33510184/how-to-change-the-mysql-root-account-password-on-centos7

반응형