Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect laravel project with xampp database

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

like image 484
Priyanka Sankhala Avatar asked Feb 18 '18 10:02

Priyanka Sankhala


People also ask

Can you use Laravel with xampp?

You will be shown how to set up a Laravel project on a local server using the Xampp development stack on a PC. Xampp is a free and open-source cross-platform web service stack package. It is used by developers to launch PHP projects such as Laravel on their local computer in order to create and test programs locally.

How to install Laravel in XAMPP?

Open a terminal and run the following command: composer global require laravel/installer to install Laravel globally. Once it’s done, you can create a fresh Laravel project with the laravel new command in the directory you’re in. In your terminal go to the root of your webserver (e.g.: cd C:\xampp\htdocs) and run laravel new your_project.

How to install Laravel on a web server?

If you already have a Laravel project in the root of your webserver then you can skip this section and jump to the next. Open a terminal and run the following command: composer global require laravel/installer to install Laravel globally. Once it’s done, you can create a fresh Laravel project with the laravel new command in the directory you’re in.

How to create a new Laravel project in terminal?

Once it’s done, you can create a fresh Laravel project with the laravel new command in the directory you’re in. In your terminal go to the root of your webserver (e.g.: cd C:\xampp\htdocs) and run laravel new your_project. Now dream a custom domain for your project. We will use laravel.test in this tutorial.

How to create a custom domain in Laravel?

In your terminal go to the root of your webserver (e.g.: cd C:\xampp\htdocs) and run laravel new your_project. Now dream a custom domain for your project. We will use laravel.test in this tutorial. Go to the following folder C:\Windows\System32\drivers\etc and open the hosts file, paste the following line and save it.


2 Answers

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.

like image 177
Ognjen Stefanovic Avatar answered Oct 19 '22 09:10

Ognjen Stefanovic


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=

like image 1
Mohamed_Abdo Avatar answered Oct 19 '22 10:10

Mohamed_Abdo