0

Recently, I installed Laravel 9 by following the steps below:

  1. First, I downloaded and installed Docker Desktop and after running it,

  2. I ran the following command in the directory where I wanted to install my Laravel project:

    curl -s "https://laravel.build/example-app" | bash

  3. After Laravel was successfully installed, I ran the following lines of code to activate sail:

    ./vendor/bin/sail up

    cd example-app

Now when I check Docker to see the services that are being run for example-app, I see:

example-app_mysql_1 mysql/mysql-server:8.0

But when I click on the "OPEN IN BROWSER" button to see a page similar to phpmyadmin, I get one of the following errors:

Error 1: This error is thrown when I enter the URL as http://localhost:3306:

localhost sent an invalid response. ERR_INVALID_HTTP_RESPONSE

Error 2: And this error is thrown when I enter the URL as http://localhost:3306:

localhost sent an invalid response. ERR_SSL_PROTOCOL_ERROR

As I need to create a new database with the same name defined in my .env file (shown below), I need to have access to mysql wizard. Besides, in the developing phase, sometimes, I may need to manipulate the database manually (with using migrations and other artisan commands).

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=example_app
DB_USERNAME=sail
DB_PASSWORD=password

How can I solve this?

2
  • 2
    Can you share your Dockerfile? And your docker-compose.yml (or docker run command if you're using that) Commented Apr 21, 2022 at 15:49
  • 1
    Opening the MySQL URL in a browser doesn't work, because MySQL doesn't use http and doesn't have a web interface. To get a web interface you can run something like phpMyAdmin. Commented Apr 21, 2022 at 17:44

1 Answer 1

1

mysql is not available through the browser. You must either install phpmyadmin or connect to mysql as a wizard through softwares such as tableplus or sequel pro or etc.

But in any case you can install phpmyadmin by adding the following code to docker-compose.

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
        - 8080:80
    environment:
        MYSQL_USERNAME: "${DB_USERNAME}"
        MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
        PMA_HOST: mysql
    networks:
        - sail

Do not forget after adding this code use sail build --no-cache to rebuild services

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.