DEV Community

Cover image for How to Set-Up MySQL with DBngin for Laravel 12 Development
Dinesh Wijethunga
Dinesh Wijethunga

Posted on

How to Set-Up MySQL with DBngin for Laravel 12 Development

Setting Up MySQL with DBngin for Laravel 12 Development

Welcome back to our Laravel 12 setup series! In the previous post, we got our PHP environment set up using Herd (or MAMP) and successfully installed a fresh Laravel 12 project. In this lesson, we're going to create a dedicated home for our application data.

While tools like MAMP include MySQL, they can present some workflow challenges. In this guide, we'll configure DBnginโ€”a streamlined and user-friendly database server manager for macOS and Windows. It enables you to run multiple versions of MySQL, PostgreSQL, and Redis simultaneously, without version conflicts.

By the end of this tutorial, you'll have a clean, isolated database server configured for your Laravel 12 application. This setup will work seamlessly with any application that requires database connectivity, not just Laravel.

๐ŸŽฏ What You'll Learn

  • How to install and configure DBngin
  • Setting up MySQL for Laravel development
  • Creating databases and managing connections
  • Connecting Laravel 12 to your database
  • Testing the database connection

๐Ÿ“‹ Prerequisites

  • Laravel 12 project set up (Part 1)
  • Basic terminal knowledge
  • macOS or Windows machine

๐Ÿš€ Step 1: Download and Install DBngin

1.1 Get DBngin

  1. Visit the official DBngin website at dbngin.com
  2. Click the 'Download For Mac' button (or 'Download For Windows' if you're on Windows)

DBngin Download Page

1.2 Install the Application

  1. Drag the DBngin app into your Applications folder
  2. Double-click the DBngin icon in Applications to launch it

That's all there is to it! You've successfully installed DBngin.

๐Ÿ—„๏ธ Step 2: Starting Your Database Server

2.1 Launch and Configure

  1. Open the DBngin applicationโ€”you'll see a clean, intuitive interface
  2. By default, DBngin offers the latest versions of MySQL and PostgreSQL
  3. For Laravel projects, MySQL is the popular choice

2.2 Create MySQL Connection

  1. Click the plus icon (+) at the top
  2. Select MySQL from the options
  3. Choose the version compatible with your processor
  4. Give it a memorable name (e.g., "Laravel Dev")
  5. Keep the default port (3306)

DBngin MySQL Setup

2.3 Start the Server

  1. Click "Create" - DBngin will download MySQL and set up the connection
  2. Click "Start" - you'll see it switch to "Stop" with a green indicator

Congratulations! Your database server is now running! But we're not done yetโ€”let's connect to it and create our database.

๐Ÿ”Œ Step 3: Connecting and Creating Your Database

Think of DBngin as a brand-new apartment building with no individual apartments. Let's create a room (database) for our Laravel app.

3.1 Find MySQL Client Path

  1. After starting your MySQL connection, click the right arrow (โ†’) button
  2. Select the second option to open terminal with the correct path

The path will look something like:

/Users/Shared/DBngin/mysql/8.0.33/bin
Enter fullscreen mode Exit fullscreen mode

3.2 Access MySQL Shell

# Navigate to MySQL bin directory
cd /Users/Shared/DBngin/mysql/8.0.33/bin

# Access MySQL shell
./mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

When prompted for a password, press Enter (DBngin's root user has no password by default).

Your terminal prompt should change to mysql>, indicating you're now inside the MySQL monitor.

3.3 Create Database for Laravel

-- Create database for your Laravel project
CREATE DATABASE laravel_12_app;

-- Verify the database was created
SHOW DATATBASES;
Enter fullscreen mode Exit fullscreen mode

You should see your new database in the list!

๐Ÿ”— Step 4: Connecting Laravel 12 to Your Database

4.1 Update Environment Configuration

Navigate to your Laravel 12 project and open the .env file. Find the database configuration section:

Before:

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
Enter fullscreen mode Exit fullscreen mode

After:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_12_app
DB_USERNAME=root
DB_PASSWORD=
Enter fullscreen mode Exit fullscreen mode

Note: DB_PASSWORD is left empty as DBngin's root user has no password by default.

โœ… Step 5: Testing the Connection

5.1 Check Database Status

Laravel provides Artisan commands to check database status and run migrations.

# Navigate to your project root
cd path/to/your/laravel-project

# Check database connection and info
php artisan db:show
Enter fullscreen mode Exit fullscreen mode

You should see output showing your database connection is successful!

Run Migrations

# Run database migrations
php artisan migrate
Enter fullscreen mode Exit fullscreen mode

If this command runs without errors, congratulations! You've officially set up your database and connected it to Laravel 12 perfectly.

๐ŸŽ‰ You're All Set!

You've just leveled up your local development setup! ๐ŸŽ‰ By using DBngin, you now have a clean, manageable, and powerful database server dedicated to your projects. Combined with Herd for PHP and the Laravel installer, you're all set with a professional-grade local environment for building amazing things with Laravel 12!

๐Ÿ“ Quick Recap
โœ… Downloaded and installed DBngin

โœ… Started the MySQL server

โœ… Created a database via command line

โœ… Updated Laravel's .env file

โœ… Tested the connection with Artisan

๐Ÿš€ What's Next?
In the next part of our series, we'll dive into:

  • Choosing and setting up a code editor
  • Essential tools for modern Laravel development
  • Configuring your development workflow.

๐Ÿ’ฌ Questions?
Got stuck or have a question? Feel free to drop a comment belowโ€”I'd love to help! ๐Ÿ˜Š

Enjoyed this tutorial? Check out more Laravel content on Dinesh Stack and follow me for more web development tips!

Top comments (0)