컴퓨팅 기술/Docker
[Docker + Wordpress] php에서 mysql 연결
DSeung
2023. 5. 23. 10:05
도커에서 아래와 같이 apm을 전부 정상적으로 설치했음에도 데이터베이스가 연결 안될 경우
아래 방법을 적용하면 됩니다.,
define( 'DB_NAME', 'myapp' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', 'secret' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
wp-config에서 호스트 부분을 localhost가 아닌 docker mysql의 이름으로 지정한 값으로 변경
제 경우 localhost => mysql
/** The name of the database for WordPress */
define( 'DB_NAME', 'myapp' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', 'secret' );
/** MySQL hostname */
define( 'DB_HOST', 'musql' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
이제 아래와 같이 정상 작동합니다.
반응형