PHP/CodeIgniter4

env파일에서 DB접속시 포트번호 표시하기

6미리 2020. 12. 16. 21:31

mysql 과 mariadb 를 같이 사용하는경우 하나가 포트 3306번을 사용하고 있다면 보통 3307번으로 포트를 지정해 놓습니다. 대부분의 PHP프로그램에서 DB환경 설정시 굳이 포트를 지정해 놓지 않았다면 자동으로 3306을 찾아 먼저 접속을 시도합니다. 그런데 3307번으로 mariadb 10을 사용하고 있으니, 접속이 안됩니다.

 

codeigniter.com/user_guide/database/configuration.html#configuring-with-env-file

 

Database Configuration — CodeIgniter 4.0.4 documentation

Note Depending on what database platform you are using (MySQL, PostgreSQL, etc.) not all values will be needed. For example, when using SQLite you will not need to supply a username or password, and the database name will be the path to your database file.

codeigniter.com

위와 같이 DB설정에서

$default['port'] = 5432;

이렇게 포트를 지정하라고 되어 있지만, env파일은 그게 아니니까 헤맵니다.

음.. 이거 어떻게 하지 고민하고 있다가, phpMyAdmin 에서 하던게 생각나서 아래와 같이 변경했습니다.

 

뒤에 3307을 붙이면 됩니다.

제가 검색을 잘 못한걸수도 있겠으나, 위와 같이 뒤에 포트 번호 3307을 써주면 됩니다.

의외로 공식 매뉴얼에도 없었습니다;; 여튼 이렇게 처리했습니다.

혹시 도움이 되길 바랍니다.