zhenxun-org / zhenxun_bot-deploy

真寻bot一键部署脚本
GNU Affero General Public License v3.0
170 stars 47 forks source link

在ubuntu容器里运行导入sql时权限不足 #21

Closed swearl closed 2 years ago

swearl commented 2 years ago

原因是 TMP_DIR="$(mktemp -d)" 这里创建的临时目录的权限是700, 然后把sql放进去后

cat > ${TMP_DIR}/sql.sql <<-EOF
CREATE USER zhenxun WITH PASSWORD 'zxpassword';
CREATE DATABASE zhenxun OWNER zhenxun;
EOF

su postgres -c "psql -f ${TMP_DIR}/sql.sql"

因为postgres不能读取root创建的700临时目录, 就出现了 psql: error: /tmp/tmp.r0lnnDTUn7/sql.sql: Permission denied