Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Doranov's avatar

How to create a new Laravel project when the root password is not empty?

I'm on Windows and I already had XAMPP installed. I gave Herd a try, but it failed to start Nginx. So XAMPP it is. My MariaDB "root" user has a password, let's say it's "password". Unfortunately "laravel new project" assumes that the root user has a blank password. I know I can change it in the .env file afterwards, but by then the creation of the database will have already failed.

Is there any way to tell Laravel what the password is before creating the project? Even better, can I set the database user as well?

If not, can I create a project, then change the .env file, and then rerun the default database migrations?

I figured out a cheesy way to do it. 1.) Run the script up to the step "Default database updated. Would you like to run the default database migrations?". 2.) Edit the .env file. 3.) Continue with the script. This works, but there has to be a cleaner way to do this.

0 likes
8 replies
MohamedTammam's avatar

How are you installing it? Using laravel new? When choosing database step, choose mysql and select no for running the migration option.

2 likes
Tray2's avatar

I would recommend using Herd, and the likely reason for it to fail, is that you have apache running on port 80 due to your xampp installation. If you shut xampp down Herd should work just fine.

As for your issue with the password just do as @mohamedtammam suggested, or remove the password from the mysql root user, or choose SQLite as your DB.

2 likes
jlrdw's avatar

Just use composer to install, then enter the credentials in .env.

I don't use xampp, but I use the zip versions of mysql, php, and apache, so it's a custom wamp.

1 like
Snapey's avatar
Snapey
Best Answer
Level 122

I think yours is the best solution. The installation is too opinionated.

You could let it install with sqlite, then edit the .env and run php artisan migrate:fresh

1 like
Randy_Johnson's avatar

https://chocolatey.org/ choco install php choco install mysql choco install composer choco install nodejs composer create-project laravel/laravel example-app

1 like
Doranov's avatar

Many thanks to everyone who replied. I've combined your replies into the following solution: 1.) laravel new laravel-test 2.) Select none (No starter kit), 0 (Pest), no (Git), mariadb, no (don't run default database migrations) 3.) Edit the .env file and set the database user and password to whatever I want 4.) Create a database called "laravel_test" (the hyphen in "laravel-test" is turned into an underscore) Note that I could have changed the database name in the .env file as well. 5.) php artisan migrate:fresh (the missing piece of the puzzle)

Herd is no doubt the best way to go, but I did not feel like ditching XAMPP.

Having a blank password for root and using root as the user seems to a common scenario, but it feels wrong to me. Even in a local development environment I think we shouldn't be lazy or complacent when it comes to security. The main reason why I'm giving Laravel a go is because of security.

Thanks once again. Now that I've got it up and running, I can code along with Jeffrey's "30 Days to Learn Laravel" course.

Please or to participate in this conversation.