8000 连接不上数据库? · Issue #80 · 4x99/code6 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

连接不上数据库? #80

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 8000 to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gzcl opened this issue Mar 3, 2021 · 3 comments
Closed

连接不上数据库? #80

gzcl opened this issue Mar 3, 2021 · 3 comments

Comments

@gzcl
Copy link
gzcl commented Mar 3, 2021

试过:docker run -d -p 666:80 -e MYSQL_HOST=IP ---这里的IP是宿主机的IP,还是宿主机的docker网关IP 172.17.0.1?

In Connection.php line 671:

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from user where (email = xx@xx.com) limit 1)

In Connector.php line 70:

SQLSTATE[HY000] [2002] Connection refused

@yoonper
Copy link
Collaborator
yoonper commented Mar 3, 2021

MYSQL_HOST 是 MySQL 主机,如果 MySQL 装在宿主机就是宿主机 IP(通常为 172.17.0.1
出现 Connection refused 请参考置顶的 常见问题#1

@gzcl
Copy link
Author
gzcl commented Mar 4, 2021

你好,终于找到原因了,/etc/mysql/mysql.conf.d/mysqld.cnf
里面绑定了127.0.0.1,注释掉就不报这个2002 错误了。不过会继续报一下错误:

root@76819b92e31a:/var/www/html# php artisan code6:user-add xx@xxxx.com xxxx

In Connection.php line 671:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'code6.user' doesn't exist (SQL: select * from user where (email = xx@xxxx.com) limit 1)

In Connection.php line 331:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'code6.user' doesn't exist

看了ISSUE ,这样解决: 启动容器的时候自动创建,如果启动时数据库连接不上则创建失败,可以重新启动一个容器或者在当前容器执行:

php artisan migrate

谢谢。

@yoonper
Copy link
Collaborator
yoonper commented Mar 4, 2021

启动容器的时候数据库连不上,自动导入数据表失败,可以重新启动一个新的容器,或者在当前容器执行:

php artisan migrate

@yoonper yoonper closed this as completed Mar 22, 2021
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
0