laradock error on phpmyadmin - can't connect - laravel

I just started using docker, laradock and laravel, after setting up the entire environment I tried to login on my phpmyadmin and I couldn't sign in.
I looked pretty much everywhere and couldn't find a way to fix it so you guys are my last hope lol.
Docker version 17.12.0-ce, build c97c6d6
Here's my docker ps
My project's .env
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
And here are the errors I am getting from phpmyadmin (localhost:8080)
#2054 - The server requested authentication method unknown to the client
mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client

The easiest solution is to revert back to an earlier version of MySQL. It's probably a good idea anyway since 8.0 is a "developer's release". Unfortunately Laradock currently has a bug that installs 8.0 no matter what you set in the .env file. I've submitted a PR on Laradock to fix this particular issue.
https://github.com/laradock/laradock/pull/1409

This is caused by an update to libmysqlclient since MySQL version 8.0.4 which has changed the default authentication method to a more secure sha256_password.
As soon as Laravel and other software packages such as PhpMyAdmin are updated to support this new and more secure authentication method this problem wil resolve itself.
If you CANNOT delete and rebuild your existing mysql data volume, simply:
Sign in to your mysql container (docker-compose exec mysql mysql -uroot -proot)
Execute ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Repeat step 2 for any other users you may have created.
If you CAN recreate your mysql data volume:
Modify your my.conf file. Under [mysqld] add the following configuration option default_authentication_plugin=mysql_native_password
Delete your mysql volume rm -rf ~./laradock/data/mysql
Rebuild the mysql container docker-compose -d --build mysql phpmyadmin

Related

How To Create A New Database For Each Tenant on Laravel Sail, Docker

I'm developing a multi-tenant app first time by using Laravel 8, Tenancy For Laravel on Docker and WSL2. My issue occures when I try to create a tenant. I want to create a new database for each tenant, but creating database trows the following error:
SQLSTATE[42000]:
Syntax error or access violation:
1044 Access denied for user 'sail'#'%' to database 'tenant-a6d0813b-a546-428d-859a-15095724fb73'
(SQL: CREATE DATABASE `tenant-a6d0813b-a546-428d-859a-15095724fb73` CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`)
I don't even know where should I start from because I'm pretty new on Docker, WLS and Laravel Sail. Before I moved this project to Docker, I was able to create databases on Xammp, but not anymore.
docker-compose.yml file is as it's shipped by Laravel exept the part that phpmyadmin is included:
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8080:80
environment:
- PMA_HOST=mysql
depends_on:
- mysql
networks:
- sail
I ran into the exact same problem today.
The problem seems to be the db user 'sail' set in the .env file.
It doesn't have the required privileges to create a database.
Opening the mysql console with the sail mysql command and trying to create a database with CREATE DATABASE test; causes the same error.
Changing the paramater in the .env file to:
DB_USERNAME=root
and rebuilding the docker container caused an error in the docker creation log and therefore mysql not running at all.
Logging into docker mysql as root and trying to set new privileges to the 'sail' user didn't help either.
What worked for me in the end was building the application with the standard
DB_USERNAME=sail
starting the application with sail up -d and then changing the .env file to
DB_USERNAME=root
After that I reset the config with sail artisan config:clear.
Ran into the same problem, what worked for me was creating an init.sql file
GRANT ALL PRIVILEGES ON *.* TO 'sail'#'%';
FLUSH PRIVILEGES;
And adding this to the mysql entry:
volumes:
- ./path/to/init.sql:/docker-entrypoint-initdb.d/init.sql
What worked for me:
I have PhpMyAdmin installed in my container and I able to login to to it using,
server: mysql
username: root
password: secret
After successful login, I navigated to the User Accounts page, selected sail and granted all the permission that was appropriate for my work and save.
This will resolve the issue of SQLSTATE[HY000] [1045] Access denied
I asked this question long time ago. I had stopped working on that project. Now, I've started a new one, faced with the same issue. I came across with my own question while searching the solution. I found it, here it's:
You should execute the following commands on your teminal:
docker-compose exec mysql bash
mysql -u root -p
password: password
GRANT ALL PRIVILEGES ON *.* TO 'sail'#'%';
FLUSH PRIVILEGES;
EXIT;
exit

Laravel can't access database

I cvurrently have a laravel application running on heroku, the issue here is, I keep getting the error that I can't connect to the database: SQLSTATE[HY000] [1045] Access denied for user 'user'#'ec2-54-74-209-179.eu-west-1.compute.amazonaws.com' (using password: YES). Now the host is wrong here, the environment files are TOTALLY different (except for the username) then what the error gives....
How can I resolve this issue?
I've tried to use the DB_URL env, but that gives the same result...
Did you set the .env correctly on what's running on their server?
You can see all your projects in laravel at TOOLS->DEPLOYEMNT->CONFIGURATIONS
add all the info and connect to the remote project. I did the same and changed the .env directly there.
and of course you have to clean all the cache cause even if you change the .env it will not work until you'll clear it
php artisan cache:clear;
php artisan config:clear;
php artisan route:clear;
Obviously this need to be executed on the project on heroku or aws (as it appears from the Error)

Laravel is using the default homestead user details to connect, even though these have been deleted

I am using laravel 5.8.6 and can connect to my database using the artisan migration tool, and can read and write to the database using tinker with no issues.
When I launch the default scaffolding it fails to connect, complaining that the login failed for user homestead#localhost.
I have deleted the .env.example file and cleared the various cache files with no success.
A full search for homestead only reveals log entries:
Illuminate \ Database \ QueryException (1045)
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from `users` where `email` =
Any ideas gratefully received.
I had the exact same problem and I just couldn't wrap my mind around how that was even possible. Turns out I seem to have changed the .env file after having started the dev server via php artisan serve. It doesn't pick up changes in the .env config at runtime and it caches the configuration.
After running
php artisan config:clear
, shutting down the dev server and restarting it, the issue was resolved and the database connection successful with the correctly set database credentials.

Laravel 5.5.6 backpack:base:install

I'm trying to install Backpack base using this comand: php artisan backpack:base:install
After few seconds I receive this error:
I tried to install backpack/generators manually but the problem is still the same.
Backpack can only be installed on an working Laravel instance. And it looks like your Laravel installation can't connect to the database. This usually happens:
A) when you haven't properly setup the .env file with your DB credentials; review your .env file; keep in mind you might also need to specify a db socket; by default homestead apps work with this db configuration:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=homestead
DB_PASSWORD=secret
B) when you're running the command outside your homestead box; SSH into homestead first, then run the installation commands;
Hope it helps.
I tried all of your ideas but it still didn't work still, thanks for the suggestions. Anyways I just created a new project in laravel 5.5 and it did actually worked.

laravel 5 - when trying to retrive data from phpmyadmin: SQLSTATE HY000 1698 Access denied for user 'root'#'localhost'

That's my first post - I hope my problem explanation will be easy to understand. I just started with Laravel5.
I want to retrive data from mysql database that was successfully created using migrations. I'm following laracast series. I created route, controller and view to display the data. Unfortunatelly, when I enter browser to see it, I constantly get this error:
`SQLSTATE[HY000] [1698] Access denied for user 'root'#'localhost'`
enter image description here
My .env and database.php files are configured. Also, I can do migrations with no error (and I see result in phpmyadmin to which I can log in). When I type php artisan tinker, I can do various operations on my databases. The problem arises only when I want to display data in my laravel site.
I did vast research of the problem and tried numerus tips like:
1.change local host to 127.0.0.1
2.change my database login and pass for homeostead, secret
3.I did
`GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY 'Your_Password';`
When I type mysql --user=root -p I can log in but command show databases acts like never ending and shows nothing.
and other ...
Now, I'm at loss for ideas what to do next, please help me. I will appreciate that a lot cos I'm really stucked at this point!
my .env file:
`DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=haslo`
I use homeostead and Laravel 5 on Windows 7
Server type: MySQL5.7.15
PHP version: 7.1
Apache/2.4.23, PHP/7.1
have a look at my answer at Unable to connect to local MySQL DB using Laravel
That could be the answer for you as well.
If you use homestead with vagrant, then laravel will be lunched inside vagrant and 127.0.0.1,3306 will mean the mysql inside vagrant, type vagrant ssh and check for the database.
Try this command:
Php artisan config:clear

Resources