# 有關在WSL上面的Postgredb(database) ## 起因 - 手動裝Postgredb 在windows上面一直遇到 .vbs檔案的執行問題 花了一天弄不 只好先遷就WSL - WSL 貌似沒有`systemctl`導致 `createdb`時出現以下service沒有啟動的錯誤 ```bash createdb: could not connect to database template1: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432" ``` ## Solution ### Reference - [起因解釋stackoverflow](https://stackoverflow.com/questions/30095546/postgresql-error-could-not-connect-to-database-template1-could-not-connect-to) - [在WSL2上正確的database安裝方法 - Microsoft][microsofttutorial] - [一般ubuntu的installation](https://help.ubuntu.com/community/PostgreSQL) ### Do > 解鈴還須繫鈴人 [name=tunchin kao] 基本上照著[microsoft的指示][microsofttutorial]走絕對沒錯 ## Postgredb補充 - [Postgredb各項權限控管](https://tableplus.com/blog/2018/04/postgresql-how-to-grant-access-to-users.html) [microsofttutorial]: https://docs.microsoft.com/zh-tw/windows/wsl/tutorials/wsl-database