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

[BUG] tarsweb, Access denied for user 'tarsAdmin' error #871

Open
yzm0080 opened this issue Nov 23, 2021 · 3 comments
Open

[BUG] tarsweb, Access denied for user 'tarsAdmin' error #871

yzm0080 opened this issue Nov 23, 2021 · 3 comments
Labels

Comments

@yzm0080
Copy link

yzm0080 commented Nov 23, 2021

What version of TARS and what language are you using?
TarsFramework v2.4.7
Mysql 8.0

What operating system (Linux, Windows, ...) and version? [e.g. CentOS 7.8]
CentOS 7.6

What runtime/compiler are you using? [e.g. JDK version or version of gcc]

Describe the bug
通过源码编译后的脚本安装Tars框架服务
./linux-install.sh MYSQL_HOST MYSQL_PASSWORD INET REBUILD(false[default]/true) SLAVE(false[default]/true) MYSQL_USER MYSQL_PORT
访问tars web,http://ip:3000
将会出现SequelizeConnectionError: Access denied for user 'tarsAdmin'@'172.16.105.228' to database 'db_user_system'的错误
原因:Mysql8.0的安全策略引起,linux-install.sh脚本创建的mysql用户tarsAdmin没有权限
登录mysql后,查看mysql.user表可以看出

mysql -uroot -p
> use mysql;
> select * from user where user='tarsAdmin';
# 可以看到tarsAdmin用户的Select_priv,Insert_priv,Update_priv等所有权限都为N

建议在脚本中兼容Mysql 8.0的情况,设置tarsAdmin的权限

grant all privileges on *.* to 'tarsAdmin'@'%' identified by 'Tars@2019';

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@yzm0080 yzm0080 added the bug label Nov 23, 2021
@ruanshudong
Copy link
Contributor

奇怪, 一直都有这句啊

@yzm0080
Copy link
Author

yzm0080 commented Nov 25, 2021

奇怪, 一直都有这句啊

tars-install.sh里是下面这样的,Mysql 8.x的GRANT应该和5.x是一样的才对
if [ echo $MYSQL_VER|grep ^8. ]; then
exec_mysql_script "CREATE USER '${TARS_USER}'@'%' IDENTIFIED WITH mysql_native_password BY '${TARS_PASS}';"
exec_mysql_script "GRANT ${MYSQL_GRANT} ON . TO '${TARS_USER}'@'%' WITH GRANT OPTION;"
exec_mysql_script "CREATE USER '${TARS_USER}'@'localhost' IDENTIFIED WITH mysql_native_password BY '${TARS_PASS}';"
exec_mysql_script "GRANT ${MYSQL_GRANT} ON . TO '${TARS_USER}'@'localhost' WITH GRANT OPTION;"
exec_mysql_script "CREATE USER '${TARS_USER}'@'${HOSTIP}' IDENTIFIED WITH mysql_native_password BY '${TARS_PASS}';"
exec_mysql_script "GRANT ${MYSQL_GRANT} ON . TO '${TARS_USER}'@'${HOSTIP}' WITH GRANT OPTION;"
elif [ echo $MYSQL_VER|grep ^5. ]; then
exec_mysql_script "grant ${MYSQL_GRANT} on . to '${TARS_USER}'@'%' identified by '${TARS_PASS}' with grant option;"
if [ $? != 0 ]; then
LOG_DEBUG "grant error, exit."
exit 1
fi

    exec_mysql_script "grant ${MYSQL_GRANT} on *.* to '${TARS_USER}'@'localhost' identified by '${TARS_PASS}' with grant option;"
    exec_mysql_script "grant ${MYSQL_GRANT} on *.* to '${TARS_USER}'@'$HOSTIP' identified by '${TARS_PASS}' with grant option;"
    exec_mysql_script "flush privileges;"
else
    exec_mysql_script "grant ${MYSQL_GRANT} on *.* to '${TARS_USER}'@'%' identified by '${TARS_PASS}' with grant option;"
if [ $? != 0 ]; then
    LOG_DEBUG "grant error, exit."
    exit 1
fi

exec_mysql_script "grant ${MYSQL_GRANT} on *.* to '${TARS_USER}'@'localhost' identified by '${TARS_PASS}' with grant option;"
exec_mysql_script "grant ${MYSQL_GRANT} on *.* to '${TARS_USER}'@'$HOSTIP' identified by '${TARS_PASS}' with grant option;"
exec_mysql_script "flush privileges;"
fi

@ruanshudong
Copy link
Contributor

我用mysql8的镜像试了, 貌似没问题?这样启动mysql8的镜像
docker run -d --restart=always -p 3306:3306 -v /usr/local/mysql-data-8:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=tars@12345 -e TZ=Asia/Shanghai mysql:8 --skip_ssl --default-authentication-plugin=mysql_native_password

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

No branches or pull requests

2 participants