-3

I'm trying to set up Laravel 6 to connect to my XAMPP MySQL (MariaDB) database and I am receiving the following error:

SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Exception trace:

  1   PDOException::("Packets out of order. Expected 0 received 1. Packet size=71")
      /Users/myname/.bitnami/stackman/machines/xampp/volumes/root/htdocs/testSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("mysql:host=192.168.64.2;port=3306;dbname=testSite", "root", "", [])
      /Users/myname/.bitnami/stackman/machines/xampp/volumes/root/htdocs/testSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

My .env file has the following setup:

DB_CONNECTION=mysql
DB_HOST=192.168.64.2
DB_PORT=3306
DB_DATABASE=testSite
DB_USERNAME=root
DB_PASSWORD=
CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
upsidedownb
  • 39
  • 1
  • 2
  • 5
  • 1
    Restart your server and then run `php artisan serve` – Tabish Feb 04 '20 at 10:19
  • It doesn't answer the question unfortunately, I did try this. It's not a matter of file size, as you can see from the question the size is only 71. – upsidedownb Feb 04 '20 at 11:37
  • I still have the same problem after running `php artisan serve`. My XAMPP server is running fine so this shouldn't be the issue – upsidedownb Feb 04 '20 at 11:39

2 Answers2

0

DB_HOST=127.0.0.1

You can do it like this should work fine. just replace your IP with localhost or 127.0.0.1.

  • I had already tried this, thanks for your suggestion. If I do this, then I get a different error "Connection refused" – upsidedownb Feb 04 '20 at 11:40
  • connection refused maybe for different reasons. say your database username and password issues. have you checked username and password ? – Anshuman Gupta Feb 04 '20 at 11:42
  • Yeah I have checked the username and password, as well as the port details. The connection refused error is the same as if I use a random string as DB_HOST – upsidedownb Feb 04 '20 at 19:30
  • Try reinstalling the XAMPP server after taking all the project and database backup. – Anshuman Gupta Feb 05 '20 at 06:30
  • https://stackoverflow.com/questions/7942154/mysql-error-2006-mysql-server-has-gone-away refer this – Anshuman Gupta Feb 05 '20 at 06:44
  • Thanks, but it's not a max packet size issue, the size it's trying to send is only 71 bytes. I've already adjusted the max packet size and this has not fixed it. – upsidedownb Feb 05 '20 at 09:17
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/207259/discussion-between-anshuman-gupta-and-upsidedownb). – Anshuman Gupta Feb 05 '20 at 10:23
0

The issue was a difference between versions of MySQL.

I reinstalled XAMPP and was able to resolve the issue.

OMR
  • 11,736
  • 5
  • 20
  • 35
upsidedownb
  • 39
  • 1
  • 2
  • 5