Reputation:
Am new to coding and Laravel. I'm following a tutorial video and at 22:31:00 I am told to edit the .env file and then connect to database using "php artisan migrate".
I manually created a file within Larevel database folder "called database.wamp" (I use WAMP to connect to mysql database) and set the .env info to;
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_DATABASE=database.wamp
DB_USERNAME=root
DB_PASSWORD=""
I have no password for my mysql database.
I've looked at many online answers to the above issue but none work.
I get the following error;
C:\wamp64\www\sites\demo1>php artisan migrate
Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied
for user ''@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = database.wamp and table_name = migrations and table_type = 'BASE TABLE')
I'd love to add more code but stackoverflow formatting never works. Clicking CTRL+K simply opens a new chrome tab. I can't even add 4 spaces before each line for more than 6 lines of code or the space bar turns into a return button and the text just moves down. Very annoying.
Upvotes: 4
Views: 7230
Reputation:
I wanted to add additional information and show what I've tried because now I'm getting a different error message.
As stated, I'm following a tutorial video and am told to created “database.wamp” file name, then run "php artisan migrate" in command prompt.
However, I keep getting "Access denied for user ''@'localhost' (using password: NO)"
Here are my .env settings
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_DATABASE=database.wamp
DB_USERNAME=root
DB_PASSWORD=""
and my mysql settings found in 'config > database'
'mysql' => [
'driver' => 'mysql',
'url' => 'database.wamp',
'host' => 'localhost',
'port' => '3306',
'database' => 'mysql',
'username' => 'root',
'password' => "",
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
I checked the port was 3306, which is the correct MySQL port (MariaDB is 3307)
Next, I created a database called database.wamp in MySQL and ran the "php artisan migrate" in command prompt. This time I get a new error message:
Unknown database 'atabase_url'
I see the text ‘database’ is missing ‘d’ but I'm unsure unsure where to find that? I checked the phpMyAdmin database and it's spelt correctly. I also checked everywhere I can think within Laravel and can't find the misspelled word?
Upvotes: 0
Reputation: 890
please go into config folder and then open database.php file. here add your database name, host and password in mysql section,it might not taking values from .env file.
if it still does not work you are using wrong DB password.
Upvotes: 1
Reputation: 18803
You must restart
your web server.
And if your problem is not resolved run these commands:
php artisan cache:clear
php artisan config:cache
Upvotes: 1
Reputation: 94
You probably used MariaDB
in WAMP
and you must change port to 3307
DB_PORT=3307
Upvotes: 1
Reputation: 15296
Where is your host and port?
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database.wamp
DB_USERNAME=root
DB_PASSWORD=
Then use command php artisan config:cache
and then php artisan migrate
Upvotes: 3