mysql로 그간 CUI로 열심히 관리해왔지만, 사실 그럴 필요는 없다. GUI로 나온 툴들도 많고 오픈소스도 있으니.. 게다가 CUI로는 DB가 조금 커졌을땐 내용 확인하기도 좀 애매해서 직관적으로 파악하기가 어려운 점도 있다.
그래서 오늘은 시놀로지 NAS에서도 쓰고 있는 phpMyAdmin을 GCP에 설치해볼까 한다.
무료이기도 하고 사용도 간단하고 꽤 많은 이들에게 검증된 애플리케이션이라 개인용으로 쓰기엔 매우 적합하다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img.png?resize=825%2C521&ssl=1)
#cd /tmp
#sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-all-languages.zip
/tmp 폴더에 간단하게 최신 phpMyAdmin을 다운로드 해두었다. 구버전이 필요하거나 이 글을 쓰는 시점보다 미래에는 더 최신 버전이 나올테니 그때는 s.xeriars.com/QhfE 에서 다운로드 받을 수도 있다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_1.png?resize=825%2C521&ssl=1)
#sudo apt-get install zip
#unzip phpMyAdmin-5.0.4-all-languages.zip
압축을 풀려니 zip을 안받아놨네… 일단 zip부터 설치한다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_2.png?resize=825%2C521&ssl=1)
#sudo mv phpMyAdmin-5.0.4-all-languages /var/www/phpmyadmin
#sudo rm phpMyAdmin-5.0.4-all-languages.zip
압축을 풀고 /var/www/phpmyadmin 디렉터리로 파일들을 이동해주었다.
다운로드 받았던 .zip 파일은 용량도 아낄겸 삭제.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_3.png?resize=825%2C521&ssl=1)
#sudo ln -s /var/www/phpmyadmin /var/www/html/xeriars
아파치 웹서버의 DocumentRoot 기본값은 /var/www/html이므로 전 단계인 /var/www에 저장을 해두면 외부에서 접근할 수가 없게 된다. 다만 구동을 하려면 무언가 있어야하니 심볼릭 링크를 생성해준다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_4.png?resize=825%2C521&ssl=1)
윈도우로 치면 단축아이콘을 만들어주는 것이므로, 외부에서 접근을 시도했을 때 원본파일에 뭘(!?) 건드리려고 해도 보안상 안전하게 된다.
이제 외부에서 접속할 수 있는 주소가 생겼다. https://자신의도메인또는IP주소/xeriars 로 접속하면 되며, 심볼릭링크는 자유롭게 설정하면 된다. 기본값을 쓰면 웹봇이나 누군가 찝적거리므로 phpmyadmin은 피하는게 좋다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_5.png?resize=980%2C552&ssl=1)
심볼릭 링크를 xeriars로 설정하였으므로 도메인 뒤에 /xeriars를 붙여서 접속.
사용자명과 암호는 mysql의 root계정을 사용하므로 사용자명에 root / 암호는 root 계정 암호를 입력하면 된다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_6.png?resize=980%2C719&ssl=1)
이렇게 루트 계정으로 접속이 안된다면, 계정을 하나 생성해서 그 계정으로 접속을 해야한다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_7.png?resize=825%2C521&ssl=1)
#sudo mysql -u root -p
#create user '아이디'@'%' identified by '비밀번호';
#grant all privileges on *.* to '아이디'@'%';
#quit;
계정을 적절히 생성해준 후 해당 계정으로 접속을 시도한다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_8.png?resize=980%2C480&ssl=1)
접속은 잘 되었으나 스크롤을 좀 내려보면 에러메시지가 떠있다.
필연적인 것이니까 걱정할 필요는 없다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_9.png?resize=980%2C169&ssl=1)
일단 빨간색 네모박스친 “여기”를 클릭.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_10.png?resize=893%2C154&ssl=1)
“Create”를 클릭.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_11.png?resize=847%2C474&ssl=1)
이런식으로 전부 OK가 뜨면 성공. 이제 다시 홈으로 돌아간다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_12.png?resize=980%2C80&ssl=1)
그래도 메시지가 떠있다. 다시 터미널로 돌아간다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_13.png?resize=825%2C521&ssl=1)
#sudo cp config.sample.inc.php config.inc.php
#sudo nano config.inc.php
환경설정파일이 없기 때문에 에러가 난 것이며, sample 파일을 복사해주면 된다.
다음은 config.inc.php 파일을 파일 에디터로 열어준다. 여기서는 nano를 사용하였다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_14.png?resize=825%2C521&ssl=1)
빨간색 네모 친 부분을 보면 blowfish_secret을 설정하는 부분이 있다. 이 부분에 해시코드를 넣어주면 된다.
s.xeriars.com/9h7-에 접속해서 간단하게 생성할 수 있다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_15.png?resize=980%2C298&ssl=1)
Encrypt 란에 아무 글자나 넣고 Hash! 를 클릭하면 위와 같이 해시코드가 생성된다. 이걸 복사해서 붙이면 된다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_16.png?resize=825%2C521&ssl=1)
이런식으로 ‘이 안에’ 넣어주고 저장해주면 끝. 이제 다시 웹브라우저로 돌아가서 홈으로 가려고 하면 다시 로그인을 하라고 나오므로 로그인을 해준다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_17.png?resize=980%2C83&ssl=1)
에러가 말끔히 해결되었다.
하지만 이것 말고도 에러가 뜨는 경우가 한가지 더 있다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_18.png?resize=980%2C74&ssl=1)
이런식으로 임시 디렉터리에 엑세스를 할 수 없는경우에 에러가 발생한다. 이 에러도 해결은 가능하다.
일단 터미널로 돌아가서 다음과 같이 진행한다.
![](https://i0.wp.com/xeriars.com/wp-content/uploads/2021/01/img_19.png?resize=825%2C521&ssl=1)
sudo mkdir tmp
sudo chown www-data:www-data tmp -R
sudo chmod 774 tmp
tmp 디렉터리를 생성해주고 소유자는 www-data로, 권한은 774로 주면 끝.
이 글을 쭉 따라왔다면 왠만하면 잘 설치되겠지만 안되면 뭐.. 구글에서 찾아야 하겠지.
대부분의 외국친구들도 비슷한 문제를 겪기 때문에 찾기가 어렵진 않다.
이상 phpMyAdmin 설치법에 대해서 써보았다.