I am new in laravel framework and I have no idea on how to view my saved data in laravel. I already edited the .env to the correct values
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:YfTvtpSEf86ZR0K+MiruFqbIrmfYzMUVT4XWtj5ovLM=
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=application
DB_USERNAME=admin
DB_PASSWORD=admin
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
am I doing something wrong? whenever i try to manipulate the database in my code it says SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES). for user "homestead"? but I already set the username into admin in my DB_USERNAME i'm so confused. Any help would be much appreciated. Thank you.
Fixed it :D Just needed to restart my laravel server. maybe its some caching issue.
Execute the following command:
composer dump-autoload -o
and also please restart your laravel application
or please check config/database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'application'),
'username' => env('DB_USERNAME', 'admin'),
'password' => env('DB_PASSWORD', 'admin'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
]
Related
I am getting database connection error in laravel. I am requesting to check my code.
I already tried to remove semicolon(;) in php.ini file
route.php:
Route::get('/Insert', 'UserController#insert');
UserController.php:
public function insert(Request $request)
{
$result=DB::insert("insert into test (id, name, email) values(?,?,?)",['1','Nirav','n#gmail.com']);
$result=DB::select("select * from test");
print_r($result);
}
database.php:
DATABASE NAME : data
TABLE NAME : test
'default' => env('DB_CONNECTION', 'mysql'),
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'database' => env('DB_DATABASE', "data"),
'username' => env('DB_USERNAME', "root"),
'password' => env('DB_PASSWORD', ""),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
],
.env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=data
DB_USERNAME=root
DB_PASSWORD=
I am inserting record in database.
you need install PDO_MYSQL driver for your PHP
Go to wamp64/www/bin/php/php* (where * is the php version you are using)
Edit file php and uncomment this line by removing the semicolon:
;extension=pdo_pgsql to extension=pdo_pgsql
Save and restart your Wamp/xampp server
check your .env and config/database again.
If you are on windows, and your php folder is not in your PATH, you have set the absolute directory in your php.ini
for example:
extension_dir = "C:/php7/ext"
and uncomment
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
Restart apache2.4 and it should work.
I hope it helps.
I am getting the following error when i reset password in laravel 5.4
Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/?p=WantAuthError s7sm7398940pgb.53 - gsmtp
"
I have correctly entered the username and password aswell as tls and smtp.gmail.com in my env. file.My mail.php file also has the correct credentials.
As for the gmail side of things:My security settings have been set to allow this to work by changing my security settings:Switching on Access for less secure apps.
And my local server,xampp has been sending emails back and forth between all the content management systems ive ever worked on for the past 2 years.I am using laravel 5.4 for the first time.
Heres my .env file
APP_NAME=MyApp
APP_ENV=local
APP_KEY=base64:---------=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mydb
DB_USERNAME=root
DB_PASSWORD=mypwd
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=myemailpwd
MAIL_ENCRYPTION=tls
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PAYPAL_MODE=
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SANDBOX_SECRET=
PAYPAL_LIVE_CLIENT_ID=
PAYPAL_LIVE_SECRET=
And heres my mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', '587'),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'myemail#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'myname'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => env('myemail#gmail.com'),
'password' => env('myemailpwd'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
Change this in your config/mail.php
'username' => env('MAIL_USERNAME', 'fallback email'),
'password' => env('MAIL_PASSWORD', 'fallback password'),
The first param is used for the key as it is defined in your .env, the second one is the default value in case the env('KEY') returns null.
The problem is right now it searches for the key 'myemail#gmail.com' in your .env file, which does not exist, the key name is 'MAIL_USERNAME'.
When I try to send an email from my laravel site I get this error
Swift_TransportException in StreamBuffer.php line 268: Connection could not be established with host lin01.hkdns.co.za [ #0]
all my details is right. my env
MAIL_DRIVER=smtp
MAIL_HOST=lin01.hkdns.co.za
MAIL_PORT=465
MAIL_USERNAME=info#mysite.co.za
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
In my mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'info#mysite.co.za'),
'name' => env('MAIL_FROM_NAME', 'Info'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
Did I miss something or is this a problem on my server?
Sometime it's possible to be "cache" in the laravel.
Use this command and try again:
php artisan config:clear
If not work, try to restart you xampp.
Another option to check if the problem is with your host or your configuration is to use a Gmail server to send a test email.
Puts this in your .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
Create or use any gmail account and enable the less secure apps more information here
first login to your gmail account and under My account > Sign In And
Security > Sign In to google, enable two step verification, then you
can generate app password, and you can use that app password in .env
file.
Your .env file will then look something like this
MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
Don't forget to run php artisan config:cache after you make changes in
your .env file (or restart your server).
Source here
I'm on a Ubuntu 15.10 Yosemite using Laravel 5.2.*
Here is my .env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Pastry
DB_USERNAME=root
DB_PASSWORD=243320
app\config\database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'Pastry'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', '243320'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
emember when I got the message:
SQLSTATE[28000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES)
Help me please!
First glance conclusion: The app you're trying to load in the browser is not using the info in the .env and database.php files you're looking at.
Are you accessing the correct URL? Aren't you trying to access a vanilla Laravel installation in a different folder? A fresh install of 5.2 has homestead as username.
Check your url
Check your virtualHost directory. Is the correct path used?
Thank you for your guidance.
I do not have access to the database.
But the construction of migrations was run properly.
But I can not run it for a test run:
public function index()
{
$com = new Categorys();
$com->name = 'ali';
$com->ename = 'hi';
$com->img = 'sdjf';
$com->save();
// return View('category.index');
}
I use the command php artisan migrate to migrate my database connection but I still get the same error and I checked everything, nothing wrong. I used the same connection that I always use in Laravel 4.2
Here is the message I get on my console:
exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES)' in C:\xampp\htdocs\Projects\blog\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:47
You need to change the values in your .env file, located in the root folder of your project.
If there is no .env file, copy the .env.example file to .env.
Laravel uses this file to protect your passwords. The values as you are setting those are only used if there is no configuration available in the .env file, homestead is the standard user there.
Take a look at your config/database.php and .env file.Maybe your database information is different.
You can go to .env file. File available on Project Root folder.
Then some here related to your database.
Then run below command to clear the old configuration cache.
php artisan config:clear
Have this problem as well. After update .env and run php artisan config:clear problem still persisted! Then after stoping the server and restart the server again with php artisan serve, problem fixed!
Change the following attribute from database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
]
to
'mysql' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'laravel',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
This must work well then run the following command:
php artisan migrate:install
I solve this issue by update .env file with config/database.php file.
here is my config/database.php structure (I am using mysql)
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'larablog'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
And .env file structure (same like config/database.php)
DB_HOST=localhost // Host name
DB_DATABASE=larablog // Database name
DB_USERNAME=root // Database User
DB_PASSWORD= // Db password(No password here)
i was getting same error after updating database info in my .env file.
fixed the problem exit command prompt and re run php artisan serve command
it helped me out and might helpful for you.
If you're using sqlite as the database, make sure you've php5-sqlite installed
sudo apt-get install php5-sqlite
If it's installed, it might be a problem with your .env file. Replace
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
with this
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306