I have this problem can anyone help me.
I create application using laravel 5.3 ,i build databse and configure the file .ENV and database.php
but when i execute the command of migration show me error as the screenshot show
Create databse in my phpmyadmin1
here when i execute the command of migration 2
Create database data in your phpmyadmin
You forgot to write DB_USERNAME = in your .env file.
In your case:
DB_CONNECTION = mysql
DB_HOST = localhost //or 127.0.0.1
DB_PORT=3306
DB_DATABASE = data
DB_USERNAME = root
DB_PASSWORD = your password ...
Whats ten problem??.
That values are in case laravel don't find anything in. Env. So change directly in the file. Env
Related
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
Windows 10, using xampp v3.2.4, Laravel 8.12. Whenever running php artisan migrate I get could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE').
I've tried just about every 'solution' on stack. I've updated the C:\xampp\php\php.ini file, by uncommenting extension=pdo_mysql and extension=mysqli plus setting extension_dir="C:/xampp/php/ext" with no luck.
I had no problems creating the database by logging into MySQL on the command line with mysql -u root and creating the database.
In the env file, `
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testme
DB_USERNAME=root
DB_PASSWORD=
anddatabase.phpit's set to'default' => env('DB_CONNECTION', 'mysql'),` I'm out of solutions. Any help is much appreciated. The database shows on the PHPMyAdmin Dashboard.
After uninstalling Laravel, then reinstalling the migrate command is now working. Although I have no idea what caused it to now work correctly.
In my Laravel (5.4) project I want to use sqlite. But when trying to access it I get an "Database does not exist" error.
In my .env file I use
DB_CONNECTION=sqlite
DB_DATABASE=database/easyresults.sqlite
I used touch database/easyresults.sqlite to create the db and successfully ran the migrations using php artisan migrate. But when accessing it using a XMLHTTPRequest, I get the error above.
After changing the path in the .env file to
DB_DATABASE=../database/easyresults.sqlite
I can acces it again, however any command line call doesn't work then.
What am I missing? Does it not work using the .env file? Do I have to use database_path('easyresults.sqlite') and put it directly into config/database.php?
Thanks a lot for your support.
If you want to have the database filename in your .env you can do database_path(env('DB_DATABASE', 'dbfilename')); in your config/database.php
then in your .env you would have
DB_DATABASE=easyresults.sqlite
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
Anyone familiar with this error i'm getting?
Please help thanks.
If you are using Laravel 5.3 do the following:
From the upgrade guides: The AuthorizesResources Trait
The AuthorizesResources trait has been merged with the AuthorizesRequests trait. You should remove the AuthorizesResources trait from your app/Http/Controllers/Controller.php file.
Seems like the problem is with your version of laravel/framework.. Running composer update should pull in the latest version (which is 5.2.39). If that doesn't work for you, then I'm not sure what else you can do. Perhaps try composer self-update before you do it.
If you run composer info laravel/framework the 4th line should show you the latest version from packagist, which is: 5.2.39.
Edit: You could try and clear your package cache: composer clearcache
Does Laravel connect to database? I had this error and it was caused by a wrong database configuration in .env file.
Try these settings in .env file:
1. Open .env file in your project's folder. Don't touch the .env.example file found in the same location as it's an example of .env default configuration. If something goes wrong with your .env file, you can copy and paste the configuration from the .env.example file to .env.
2. Change the following 4 lines to your own configuration:
DB_HOST=localhost
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=
DB_DATABASE It's the name of your database. Should be 'forge' by default or check your phpMyAdmin to determine which database you need to use. You can create a new database if you're an administrator of phpMyAdmin ('root' user).
DB_USERNAME This is your username when you log in to phpMyAdmin. Should be 'forge' by default.
DB_PASSWORD Your phpMyAdmin should not be protected with password by default. The password is set later manually. In case you'll set the password, add it to DB_PASSWORD line after you do so.
3. Save the modified .env file and restart the Apache server.
Try to access your webpage again. This worked for me. I hope it's gonna work for you, too.
P.S. If it doesn't work, check if the .env configuration is right for you. Or use php artisan config:clear to clear cache.