How to connect laravel project with xampp database - php

I have a basic issue in laravel setup.
I have setup laravel 5.5 using php7.0(cli) and for artisan migrate I have install the mysql server on my system (I have already xampp on my system) so now my Laravel project access the mysql cli (not xampp which I access with phpmyadmin) how can I connect my laravel with xampp database.
currently its direct configure with cli php and mysql-server
Thanks

You have .env file in your project root folder. There you can edit:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database_name
DB_USERNAME=root
DB_PASSWORD=
By default, XAMPP root username is root, there is no password and port is 3306.
Obviously, you have to start MySQL in XAMPP control panel.

Go to .env file in your project root folder, there you can edit:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testdatagym
DB_USERNAME=root
DB_PASSWORD=

Related

How do I connect Laravel Sail to a MySQL GUI?

I am using Laravel Sail/ Docker for the first time. I have got my site running fine but the issue is that I cannot access the DB via a GUI (Sequel Pro). I have added the default credentials from my env but cannot access. But seem to be able to run php artisan migrate. Does anybody have any tips for how I can debug this?
This is my .env file:
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=my-db
DB_USERNAME=sail
DB_PASSWORD=password
The solution for you might be in the last comment here by Lorenzo Franzone: changing the SequelPro version.
Rather than this though, I dropped the version of MySQL in docker-compose from 8.0 to 5.7 to work with my very old version of SQLYog and: Bingo! It worked.
Simple, you must change DB_HOST=mysql to DB_HOST=127.0.0.1
Have a good day.

Laravel artisan migrate error: "zsh: illegal hardware instruction php artisan migrate"

I'm using Laravel 7, when I launch from terminal php artisan migrate, I get this error
zsh: illegal hardware instruction php artisan migrate
All other artisan commands works fine like php artisan make:model or php artisan make:migration
System requirements:
PHP 7.4.5 (cli)
Zend Engine v3.4.0
MacBook Pro Catalina 10.15.4
Thank you
Just resolved yet.
I'm using MAMP PRO for the virtual server
The problem was in the db configuration, I added in the .env file
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
The default configuration in the .env file didn't work for me, this configuration will work
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=8889
DB_DATABASE=dbname
DB_USERNAME=root
DB_PASSWORD=root
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

Laravel can't connect to XAMPP MySQL database (Windows)

I can't connect to MySQL/MariaDB database (XAMPP) using Laravel, but I can through mysqli and PDO classes using the same configurations.
.env file
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=root
DB_PASSWORD=toor
This code works on Linux (mysqld) but on Windows I get
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed
error.
Please help me
PHP version: 7.3.11
Laravel version: 5.7.20
MariaDB version: 10.4.8
Change localhost to 127.0.0.1 and it should work for you.
run:
php artisan cache:clear

too many symbolic links after executing php artisan migrate?

i tried to run php artisan migrate , but it shows this error
env:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=APP
DB_USERNAME=root
DB_PASSWORD=
running xampp vm , laravel 5.5

Strange behaviour Laravel Homestead Database Connection

I am experiencing a peculiar error working with Laravel, Homestead and MySQL. This is the part of my .env file related to the database:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33060
DB_DATABASE=mydatabasename
DB_USERNAME=homestead
DB_PASSWORD=secret
If I set the port to 3306 I can access the tables from my application but I cannot execute commands from Terminal such as php artisan migrate. If I set the port to 33060 I can execute commands from Terminal but I cannot access the tables from my application.
Your application is running on the IP provided in Homestead.yaml so when localhost is relative to your application port 3306 works. When running artisan while not SSH into your vagrant vm you are running the command relative to the localhost of your machine, not the vm, so your'e trying to run the migrations against a machine with no database.
The reason that port 33060 works for your local machine is because Homestead by default forwards this port to your vagrant virtual machines port 3306. But due to your .env now specifying port 33060 the vagrant virtual machine now can not reach port 3306.
Leave the DB_HOST set to 127.0.0.1 with port 3306 and SSH into your vagrant vm via the vagrant ssh command to run your migration command.
Or alternatively you could have multiple .env files for your various environments

Categories