Laradock Laravel database connection refused
Laradock Laravel database connection refused
Laradock is a PHP development environment which runs on Docker. It is a collection of images such as Nginx, Apache, MySQL, Composer, Supervisord, Redis, etc. that required for your application development. Starting with Laradock is pretty easy with the following command:
sudo docker-compose up -d nginx mysql phpmyadmin redis workspaceThe above command will run all these images separated and automatically connect to your workspace environment. But in some cases connecting with the database will create the error with php artisan migrate command.
SQLSTATE[HY000] [2002] Connection refused
That is because we have the following settings in the .env file to connect with the database.
.....
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
.....To connect your application with MySQL through Laradock, we have to set the DB_HOST=mysql instead of DB_HOST=127.0.0.1
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laraqueue
DB_USERNAME=root
DB_PASSWORD=rootBut sometimes not only this works for the MySQL connection. Go to the laradock directory and find my.cnf file under the mysql directory and add the default_authentication_plugin=mysql_native_password and the file should look like the below.
[mysqld]
sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
character-set-server=utf8
default_authentication_plugin=mysql_native_passwordOnce you added this to your file you have to rebuild the mysql image with docker-compose build mysql and again start the service. If it’s still not connecting to the Laravel, then access the mysql terminal and the following changes.
sudo docker exec -it <mysql_container_id> bashmysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER USER 'default'@'%' IDENTIFIED WITH mysql_native_password BY 'secret';Helpful Link
Related Posts:
Laradock Laravel database connection refused的更多相关文章
- “psql: could not connect to server: Connection refused” Error when connecting to remote database
		问题: I am trying to connect to a postgres database installed in a remote server using the following c ... 
- 【MongoDB】 Failed to connect to 127.0.0.1:27017, reason: Connection refused
		由于项目需要,在一台虚拟机上安装了MongoDB,但是在启动的时候,出现如下错误: [root@localhost bin]# ./mongo MongoDB shell version v3.4.0 ... 
- error: not found: value sqlContext/import sqlContext.implicits._/error: not found: value sqlContext /import sqlContext.sql/Caused by: java.net.ConnectException: Connection refused
		1.今天启动启动spark的spark-shell命令的时候报下面的错误,百度了很多,也没解决问题,最后想着是不是没有启动hadoop集群的问题 ,可是之前启动spark-shell命令是不用启动ha ... 
- Caused by: java.net.ConnectException: Connection refused: master/192.168.3.129:7077
		1:启动Spark Shell,spark-shell是Spark自带的交互式Shell程序,方便用户进行交互式编程,用户可以在该命令行下用scala编写spark程序. 启动Spark Shell, ... 
- Neo4j下执行cypher-shell时,Connection refused问题解决?
		不多说,直接上干货! 问题现象 root@zhouls-/bin# ls cypher-shell neo4j neo4j-admin neo4j-import neo4j-shell tools ... 
- postgres登录失败Connection refused与SSL off失败
		连接失败问题 使用postgres数据库连接工具测试,遇到两次失败 第一个登录失败问题 Connection to 192.168.XX.XX:5432 refused. Check that the ... 
- VNC connect:Connection refused(10061)
		在Windows机器上使用VNC Viewer访问Linux服务器,有时候会遇到"connect:Connection refused(10061)"这个错误,导致这个错误出现的原 ... 
- telnet报“Unable to connect to remote host:Connection refused”错误
		Linux下面telnet ip 端口号 报错误"Unable to connect to remote host:Connection refused"的时候,大部分是目标机的端 ... 
- ZooKeeper集群搭建中的Connection refused而导致的启动失败
		1. 前言 每一次搭建集群环境都像一次战斗,作战中任何一个细节的出错都会导致严重的后果,所以搭建中所需要做的配置如系统配置.网络配置(防火墙记得关).用户权限.文件权限还有配置文件等等内容,都必须非常 ... 
随机推荐
- 微信小程序的页面跳转==编程式导航传参 和 标签的方法传参==以及如何过去传递过来的参数
			小程序导航传参接收传递过来的参数 在onload中 实例 
- AS3动画效果常用公式
			缓动公式: sprite.x += (targetX – sprite.x) * easing;//easing为缓动系数变量 sprite.y += (targetY – sprite.y) * e ... 
- 三元组[01 Trie计数]
			也许更好的阅读体验 \(\mathcal{Description}\) \(\mathcal{Solution}\) 有两种方法都可以拿到满分 \(Solution\ 1\) 考虑枚举\(y\) 建两 ... 
- 模板模式(Template Pattern)
			模板模式(Template Pattern) -- 定义一个操作中的算法的骨架,而将一些步骤延迟到子类中.Template Method使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤. ... 
- Vue自定义指令和自定义过滤器
			一.自定义指令: 自定义指令分为两种:全局自定义指令和局部自定义指令 全局指令指所有组件都可以使用,局部指令是只有在当前组件中才可以使用. 如,我们现在有个需求,当一个输入框获取焦点时,显示出一个di ... 
- windows下安装mysql-8.0.18-winx64
			1.下载安装包 安装包现在地址: https://dev.mysql.com/downloads/mysql/ 2.解压缩至安装目录 解压缩下载之后的zip,我这里使用的安装路径为: C:\Progr ... 
- SVN_05用戶管控
			安全性设置 [1]在左侧的User上点击右键 输入上面的信息,点击OK,我们就创建一个用户了. 说明:注意到了下面图中的Groups,是的,也可以先创建组,把用户添加到各个组中,然后对组进行授权,操作 ... 
- SQL SERVER 中如何获取日期(一个月的最后一日、一年的第一日等等)
			https://blog.csdn.net/deepwishly/article/details/9101307 这是计算一个月第一天的SQL 脚本: SELECT DATEADD(mm, DAT ... 
- 如何将SolidWorks文件另存为.obj文件及如何打开.obj格式文件
			原网站:http://fans.solidworks.com.cn/forum.php?mod=viewthread&tid=40238) OBJ文件是Alias Wavefront公司为它的 ... 
- 一次实战CTF-WEB(多重登录机制中的缺陷)
			要求登录admin账号 1.登录界面 我们发现有找回密码这个易受攻击点 2.直奔找回密码 通过观察前两个阶段url(reset1.htm1 reset2.html),我们推测出了第三个阶段的url(r ... 
