Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
swearl opened this issue Jun 10, 2022 · 0 comments
Closed

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

swearl opened this issue Jun 10, 2022 · 0 comments

Comments

@swearl
Copy link

swearl commented Jun 10, 2022

原因是 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants