I recently installed mac OSX. I installed latest version of mamp.
I was trying to setup my database, but i got this error.
Access denied for 'root#localhost' (using password: NO)
my .env file --
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=some
DB_USERNAME=root
DB_PASSWORD=
My MySQL port is 3306, Apache port is 80 (I changed it).
I don't change the password of PhpMyAdmin. But I get an error like this.
So I tried entering some password, then it is giving me same error with password using: YES
How can I fix it?
If you are using MAMP try this.
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=some
DB_USERNAME=root
DB_PASSWORD=root
Open your MAMP
There your will see 3 options
1. Preferences
2. Open WebStart Page
3. Start / Stop Servers
Click second one [ Open WebStart Page]. It will open mamp info page. Under MySQL area you can see your database connection details.
Hope it will help you.
Related
I'm taking a course of Laravel, and I'm with some problems during the Databases Module...
It's about "php artisan migrate", when I try to do this command, appears me this message: After do the command
That's my .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=
(I've already try put password at .env, but still the same)
(#Suleman and #John Lobo, can you make an answer so that I can rate it as correct?!)
It's just php artisan config:cache after some changes at .env and database.php (like #John Lobo said)
The error message is telling you the issue - that the user 'root' doesn't have access to the database without a password being specified.
Do you know your root password?
Has one been set?
If you know your password add it to your .env file.
If one hasn't been set read the manual for mysql/mariadb on your operating system for how to set the root password - then add it to the .env file.
An PDOException(code: 1045) error occurs when laravel connects to mysql yet the credentials allow me to log in via phpmyadmin suggesting the credentials are correct.
Error message:
(PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user 'host.domain.com'#'localhost' (using password: YES)
.env file:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=host.domain.com
DB_USERNAME=host.domain.com
DB_PASSWORD=password_here
PHP version is 7.2.31
Laravel Framework version is 6.13.1
CentOS server (note cant make the error occur on my Windows laptop with WAMP)
If I quoted the DB_DATABASE, DB_USERNAME and DB_PASSWORD fields in .env the application worked. I have no further explanation of why considering there are no spaces in the values for these fields.
Revised .env file:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE="host.domain.com"
DB_USERNAME="host.domain.com"
DB_PASSWORD="password_here"
I moved the Laravel project from localhost to server. Which I have done every step on the server.
I am able to view the login page on my server. The problem is I am not able to connect with my MySQL server.
My .env file:
APP_NAME=Transport
APP_ENV=local
APP_KEY=base64:mrakeyidharhaikonsdf
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=transport_db
DB_USERNAME=root
DB_PASSWORD=mypass
I tried to change the host to 127.0.0.1 and also tried to put my server's IP address. It didn't helped me. Am I missing something?
My error:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO) (SQL: select count(*) as aggregate from users where email = user.email#gmail.com)
I know this question may have answers already on Stack Overflow. But I have different issue here.
To be honest, while working on Laravel 6, I also faced this issue many times and probably was unable to figure out the solution. I tried commands like
php artisan config:cache and php artisan config:clear, but these two commands didn't help.
To come over this issue, you have to execute all the below commands:
php artisan route:cache
php artisan route:clear
php artisan config:cache
php artisan config:clear
php artisan optimize
Note: Make sure in .env you have add db_password and it is not null and also check if your db_password uses any special character. Always enclose them in "".
Example:
DB_PASSWORD="%123456%"
To debug this issue you can also create a test route and then dump the .env variable there to check if they have the correct values or not.
Route::get('/test/env', function () {
dd(env('DB_DATABASE')); // Dump 'db' variable value one by one
});
Note: Please make sure to restart your server.
Make sure your database credentials and database host are set correctly:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="your_database_name"
DB_USERNAME="put_db_user_name _here"
DB_PASSWORD="put_db_password_here_if_have_set"
If you have not set any database password then add:
DB_PASSWORD=""
The problem is that the project made a cache file. 'config.php' must be deleted in order to allow the system to restart and you can do so by locate this file and deleting it:
bootstrap/cache/config.php
I was working in the Laravel framework using homestead and had such a problem. In fact, this error was because I did not create the database in Vagrant. So, I created the database. In more details:
run vagrant ssh to get homestead command line.
run mysql to start the MySQL command line client.
run create database database_name; to create your database. Note that the database should be inside two ` (not ') marks.
Modify the .env file of the Laravel project as below:
DB_CONNECTION=mysql
DB_HOST=192.168.10.10
DB_PORT=3306
DB_DATABASE=askidb2
DB_USERNAME=homestead
DB_PASSWORD=secret
(if you previously made your model and configured files in Laravel projects for creation tables), run php artisan migrate in the command line of the project's folder. This causes it to create tables in the askidb2 database.
(perhaps optional for you) since before I set needed files for seeding the question table I just run php artisan db:seed to seed my desired table(s).
If you use Homestead to serve your application, you must connect to the Homestead built-in database. Otherwise, I get an error (SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost') when I try to connect to the MySQL database that is installed on my Mac.
Here is how I connect to the Homestead database. I am not sure why the host → 127.0.0.1 from the Laravel documentation doesn't work.
In the .env file
DB_CONNECTION=mysql
DB_HOST=192.168.10.10
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=homestead
DB_PASSWORD=secret
I use Sequel Pro as the GUI to manage the database, and here is how I connect Sequel Pro to the Homestead MySQL database.
Connect with standard mode
Host: 192.168.10.10
User: homestead
Password: secret
Port: 3306
Connect with SSH mode
So the problem is mine. I apologize for that.
I missed to put my DB_PASSWROD inside "". So that caused my two hours.
I have the password which contains some special characters at the beginning. So it should be inside the "" to avoid the problems.
For example, if my password is "%helloworld#",
then in the .env file, it should be:
`DB_PASSWORD="%helloworld#" `
Previously, I had
`DB_PASSWORD=%helloworld#
I had this error while my connection with the database was established. The problem was that I was on localhost, not 127.0.0.1.
First
DB_DATABASE="your_database_name"
DB_USERNAME="put_db_user_name _here"
DB_PASSWORD="put_db_password_here_if_have_set"
Then type
php artisan config:clear
This will make your problem clear. Then type
php artisan migrate
I had this error because my XAMPP user Account access for root and password did not match Laravel .env database DB_USERNAME & DB_PASSWORD.
This will Work:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="your_database_name"
DB_USERNAME="put_db_user_name _here"
DB_PASSWORD="put_db_password_here_if_have_set"
This may also be due to the DB_PORT. Go to the PhpMyAdmin Database server and check the server.
So I changed from this
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
to
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3307
Change the .env as follows
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="Your DB name"
DB_USERNAME=root
DB_PASSWORD=
and then run php artisan config:cache
and then run php artisan migrate:fresh --seed
and then run php artisan serve
Please make sure to have the same db name in .env file and db name in php myadmin
Kindly check your mysql port no as well.
If you have changed your xampp mysql port, then do check PORT Number in your projectfolder ".env" file as well as "database.php" file.
In my case, if I have Bitnami WordPress. It's a service using an Apache/localhost address, so my XAMPP instance is only accessible via 127.0.0.1 and when accessing localhost I got 'Access denied error ...'. Then when I stop the Bitnami service, everything is back to normal.
so I want to deploy my existing Laravel project into my digital ocean VPS
I used this tutorial and I uploaded my site successfully.
My .env file is:
APP_ENV=local
APP_KEY=my app key
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=my ip
DB_PORT=3306
DB_DATABASE=form
DB_USERNAME=root
DB_PASSWORD=my pass
But here is the problem: I used MySQL and created and ran
php artisan migrate
and got these errors:
[Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = form and table_name = migrations)
and
[PDOException] SQLSTATE[HY000] [2002] Connection refused
In your .env file, change DB_HOST from 127.0.0.1 to localhost
Put string:
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
after DB_PASSWORD=
It works for MAMP. Set your path to mysql.sock
In your .env file, change DB_HOST from 127.0.0.1 to localhost
and then
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
This worked for me.
There are a few possibilities why your getting this error.
database server isn't started, check if you can still use your phpmyadmin. If you can still use it then nothing is wrong with your database server.
wrong config; check username, password and server settings in both your .env file and your config/database.php
no privileges to the server and or database with given credentials
Looking at the steps you already took I think it's the last.
Check to see if this user has access to the database from the remote location. By default the root user has access to the server locally (localhost,127.0.0.1 and ::1).
So check to see if the user has access from either your remote ip or from anywhere.
As you are using digitalocean I would suggest to check if they have a specific configuration to connect to mysql database.
SELinux might be the cause.
Set this rule and try again:
sudo setsebool -P httpd_can_network_connect_db=1
After long hours this worked for me:
Changing the port in php My Admin previously 8889
APP_NAME=laravel
APP_ENV=local
APP_KEY= YOUR KEY
APP_DEBUG=true
APP_URL=127.0.0.1
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
and then
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
Before you do changes as per instructed above,
check if your database server running or not. If you are using command prompt, running mysql.server status or mysqld status shall show the database status.
If the database is running, check if the dbuser is allow to connect from '%' or 'localhost' or '127.0.0.1'. If not, just grant the user access from '%'
If you have done 1 and 2 and still can't connect, see if the db user is allow to access the schema. If not, grant access to the schema
If you reach here and still got the same error, try to restart you web server.
My composer was installed globally, i run php artisan serve without starting xampp & getting this error. After running my xampp server, it's working fine from my side.
In attempt to provide a solution for those of you that have not found success in any of the already mentioned answers, I will share my solution.
Coming from Windows 10 I was of the understanding that the password for the root user was always blank thus my .env file looked as follows:
DB_USERNAME=root
DB_PASSWORD=
On Mac, the password is defaulted to "root" also. Changing my .env file to look as follows fixed my issue:
DB_USERNAME=root
DB_PASSWORD=root
in your .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ur_db_name
DB_USERNAME=ur_db_username
DB_PASSWORD=ur_dbuser_password
If you are using XAMPP on Mac, just use the embedded IP Address from your XAMPP Dashboard as DB_HOST instead of 127.0.0.1 or localhost.
If It still refuses to connect deal with a user but stick on that idea.
Hey there i tried to setup the laravel-framework locally.
So i installed laravel and mamp => worked.
Next i configured database-settings:
Mamp:
Host: localhost
User: root
Password: root
Next i created database in mamp-phpmyadmin, name: laravel_app
All i did in laravel is, i edited ".env" in root directory of my laravel-app:
APP_ENV=local
APP_DEBUG=true
APP_KEY=secret_app_key
DB_HOST=localhost
DB_DATABASE=laravel_app
DB_USERNAME=root
DB_PASSWORD=root
CACHE_DRIVER=file
SESSION_DRIVER=file
When i try to run migrate:install:
php artisan migrate:install
i get:
exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES)' in /Users/my_computer/laravel_app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47 etc..
But what is wrong now?
Anybody could help with this?
Greetings and thanks!!
Check the current version MAMP. Say you 5.6.10
sudo nano ~/.bash_profile
Make sure that you export the same version of php
export MAMP_PHP=/Applications/MAMP/bin/php/php5.6.10/bin
Good luck =)