암호없이 리눅스 루트 사용자 mysql 루트 액세스 허용 액세스 할 수

cPanel에서 루트로 로그인하고 호스트 이름과 암호없이 “mysql”을 입력하면 mysql 루트 사용자에게 직접 액세스 할 수 있습니다.

Linux 루트 사용자가 cPanel에서와 동일한 방식으로 mysql 루트 사용자에게 암호를 덜 사용하는 비 서버 서버 중 하나에 대해이 작업을 수행하고 싶습니다.

이것이 가능한가 ?



답변

가장 쉬운 방법은 ~ / .my.cnf 파일의 client 섹션을 사용하여 자격 증명을 추가하는 것입니다.

[client]
user=root
password=somepassword
...

루트로만 파일을 읽을 수있게하는 것이 좋습니다.


답변

mysql 5.7+의 경우 초기 설정에 빈 암호를 설정하면 mysql이 자동으로 auth_socket전략 으로 사용 됩니다. 전략을 변경하지 않고 비밀번호를 업데이트해도 아무런 결과가 없습니다. 사용자가 인 경우 항상 비밀번호를 사용하지 않고 로그인 할 수 있습니다 root.

해결 방법
다음 명령을 실행하여 인증 전략을 변경하고 비밀번호를 설정하십시오.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''

참조 : https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/


답변

MySQL 5.6.6부터 mysql_config_editor를 사용하여 자동 로그인하는 암호화 된 파일을 만들 수 있습니다.

mysql_config_editor set --login-path=client --host=localhost --user=root --password

그런 다음 프롬프트가 표시되면 비밀번호를 입력하십시오.

참고 : 비밀번호에 ‘#’이 있고 다른 문자가 있으면 비밀번호를 입력 할 때 작은 따옴표를 사용하십시오.


답변

mysql 루트 암호 만 포함 된 파일을 만들고 루트 만 읽을 수 있습니다.

# ls -l /root/.mysqlpw
-rw------- 1 root root 7 2013-08-19 13:24 /root/.mysqlpw

당신은 데이터베이스를 가져올 수 있습니다

# mysql -u root -p`cat /root/.mysqlpw ` yourdatabase < databasedump.sql

또는 데이터베이스에 연결하고 mysql 명령을 발행하십시오.

# mysql -u root -p`cat /root/.mysqlpw ` yourdatabase
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20460
Server version: 5.1.63-0ubuntu0.10.04.1 (Ubuntu)

Copyright (c) 2000, 2011, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| yourdatabase       |
+--------------------+
3 rows in set (0.00 sec)

mysql> show tables;
...


답변