mysql CLI는 연결할 수 있지만 WordPress는 연결할 수 없는 이유는 무엇입니까?
워드프레스(php-fpm/nginx) 서버를 가지고 있는데 완전 새로워.CentOS에서 실행 중.바닐라 mysql-server 이미지로 만든 도커 컨테이너도 있어요
MySQL 구성
포트로 동작하고 있다.3306
및 모든 MySQL 사용자는 호스트와 함께 MySQL에 등록되어 있습니다.172.17.0.1
(예:root@172.17.0.1
)는 도커의 게이트웨이 IP입니다.도커 컨테이너는 앤서블 플레이북을 사용하여 설치됩니다.모든 구성 설정은 매개 변수화되며, 이러한 매개 변수는 WordPress 구성 파일 및 MySQL 도커 설치 중에 루트 암호와 같은 정보를 입력하는 환경 변수를 포함하여 적절한 모든 위치에서 사용됩니다.여기서 관련 데이터베이스를 설정합니다.
WordPress 구성:
이것은 두 부분으로 나뉘어져 있는데, 그 중 관련된 것을 포함시키겠습니다.응답 가능한 플레이북에서 이 코드는 WordPress 테이블과 사용자를 설정합니다(성공적).
- name: Create WordPress database
mysql_db:
name: '{{ wp_db_name }}'
state: present
login_user: root
login_password: '{{ mysql_root_password }}'
login_host: '{{ docker_mysql_ip }}'
- name: Create WordPress database user
mysql_user:
name: '{{ wp_db_user }}'
password: '{{ wp_db_password }}'
priv: '{{ wp_db_name }}.*:ALL'
state: present
login_user: root
host: '{{ docker_gateway_ip }}'
login_password: '{{ mysql_root_password }}'
login_host: '{{ docker_mysql_ip }}'
그리고 관련 wp-config.php:
define('DB_NAME', 'wordpress');
define('DB_USER', '{{ wp_db_user }}');
define('DB_PASSWORD', '{{ wp_db_password }}');
define('DB_HOST', '{{ docker_mysql_ip }}');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
wp-admin으로 이동하면 구체적으로 다음과 같은 문제가 발생합니다.Warning: mysql_connect(): Permission denied in /srv/wordpress/wp-includes/wp-db.php on line 1473
'데이터베이스 연결을 확립하는 동안 오류가 발생했습니다'라는 제목의 상태 코드 500.
헷갈리는 부분
wp-config.php 파일을 확인해보니 사용자 이름, 비밀번호 및 데이터베이스 이름이 모두 정상입니다.호스트, 사용자 및 비밀번호를 복사/붙여넣을 때wp-config.php
커맨드 라인의 각 위치에 배치됩니다(예:mysql -u wordpress -p -h 172.17.0.2
Wordpress 데이터베이스를 볼 수 있을 뿐만 아니라 연결할 수도 있습니다.
정리하면
명령줄 사용 시 MySQL은 제대로 연결할 수 있지만 Wordpress는 연결할 수 없습니다.Wordpress나 PHP에 대해서도 잘 모르기 때문에, 문제의 로그가 어디에 위치할 수 있는지 어떤 아이디어라도 주시면 감사하겠습니다.
MariaDB를 사용하는 Debian 9.1에서 이 문제가 발생했지만 Oracle MySQL에서도 마찬가지입니다.명령줄에서 쉽게 로그인할 수 있었지만 PHP가 데이터베이스에 액세스할 수 없었습니다.
알아내는 데 몇 분이 걸렸지만, 이전 서버에서 Arch Linux를 사용하던 시절부터(참고로) 이 명령어가mysql_secure_installation
연결을 받아들이기 위해 필요했습니다.
한 번 해봐, 나한테는 효과가 있었어.
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] n
... skipping.
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
MySQL 컨테이너에서는 다음 환경과의 인증에 MySQL 네이티브 비밀번호를 사용합니다.
MYSQL_DEFAULT_AUTH=mysql_native_password
그런 다음 MySQL 컨테이너를 재시작하거나 재구축합니다.
언급URL : https://stackoverflow.com/questions/44685984/why-can-mysql-cli-connect-but-not-wordpress
'programing' 카테고리의 다른 글
Wordpress rest api에서 초안 가져오기 금지 (0) | 2023.03.19 |
---|---|
componentWillReceiveProps에서 변경된 소품을 확인하는 방법 (0) | 2023.03.19 |
html 대신 일반 텍스트를 출력하는 angularjs (0) | 2023.03.19 |
DD/MM/YYY 날짜 형식(Moment.js) (0) | 2023.03.19 |
반응 - 순수 상태 비저장 구성 요소를 내보내는 방법 (0) | 2023.03.19 |