Related
Background: i installed php7.2 using brew then installed mysql using brew.
mysql Ver 8.0.19 for osx10.14 on x86_64 (Homebrew). Then created my lumen project using composer
composer create-project --prefer-dist laravel/lumen blog
i'm trying to insert data into my table and it throws the error in postman
SQLSTATE[HY000] [1045] Access denied for user 'username'#'localhost'
This is my .env file
APP_NAME=Lumen
APP_ENV=local
APP_KEY= 9887765535434424354566gfr547633
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL=
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=pqueue
DB_PASSWORD=password
DB_STRICT_MODE=false
DB_SOCKET=/tmp/mysql.sock
CACHE_DRIVER=array
QUEUE_DRIVER=database
in my config>database.php i have the default settings
return [
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => env('DB_PREFIX', ''),
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'strict' => env('DB_STRICT_MODE', true),
'engine' => env('DB_ENGINE', null),
'timezone' => env('DB_TIMEZONE', '+00:00'),
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 5432),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => env('DB_PREFIX', ''),
'schema' => env('DB_SCHEMA', 'public'),
'sslmode' => env('DB_SSL_MODE', 'prefer'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 1433),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => env('DB_PREFIX', ''),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => 'predis',
'cluster' => env('REDIS_CLUSTER', false),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DB', 0),
],
'cache' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
],
];
`
i'm not sure what could be the issue.
When i run php artisan migrate:refresh or php artisan migrate --env=production
In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user 'pqueue'#'localhost' (using password: YES) (SQL: select * from information_schema.ta
bles where table_schema = test and table_name = migrations and table_type = 'BASE TABLE')
In Connector.php line 70:
SQLSTATE[HY000] [1045] Access denied for user 'pqueue'#'localhost' (using password: YES)
But i gave grant access to all tables in test database already
GRANT ALL on test.* to pqueue#localhost;
I was able to use pqueue credentials to create a table and insert data in the test database by using the mysql console. so i know the user has sufficient previllages.
Can some one please help me debug?
I resolved my issue.In case if anybody else has a similar issue, please make sure your mysql user's password does not have a "#" in it.
I use Laravel + SQL Server deploy to GAE, when connect to external SQL Server, I get error
could not find driver
but in my local environment it works, so hope someone can help.
.env
DB_CONNECTION=sqlsrv
database.php
'sqlsrv' =>
['driver' => 'sqlsrv',
'host' => 'host',
'port' => '1401',
'database' => 'database',
'username' => 'username',
'password' => '',
'prefix' => '',]
Make sure of the PHP version you use (for me homestead currently using php 7.1, so I installed php7.1-sybase)
sudo apt-get install freetds-common freetds-bin unixodbc php7.1-sybase
Driver:
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'db'),
'port' => env('DB_PORT', 'port'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', 'pass'),
'charset' => 'utf8',
'prefix' => '',
]
After completed my project I deiced switch mysql to mongodb. I am using Laravel 5.4 version and for mongodb use jenssegers. For laravel mongdb installation I follow jenssegers installation documentations and installation successfully completed. But after installation I go for migration and use command php artisan migrate. When I use this command shown error InvalidArgumentException in /vendor/mongodb/mongodb/src/Database.php line 83: $databaseName is invalid:
My database.php
'default' => env('DB_CONNECTION', 'mongodb'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', 'project_db'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
'database' => 'admin' // sets the authentication database required by mongo 3
]
],
],
My .env
DB_CONNECTION=mongodb
DB_HOST=localhost
DB_PORT=27017
DB_DATABASE=admin
DB_USERNAME=
DB_PASSWORD=
And I also facing one more problem if whatever I change in .env and database.php like if I change port 27017 to 3303 but on browser shows 27017. I cleared cache and all. I don't know what is problem in my code.
These are the steps Envoyer (made by Laravel's creator) takes to deploy an app on production -- I've annotated them below:
# Clear the old boostrap/cache/compiled.php
php artisan clear-compiled
# Recreate boostrap/cache/compiled.php
php artisan optimize
# Migrate any database changes
php artisan migrate
I am working on xamp, using laravel 5.2 and trying to connect oracle database
here I want to get values in tinker:
DB::table('dept')->get();
with this error:
PDOException with message 'could not find driver'
my .env file
DB_CONNECTION=sqlsrv
DB_HOST=localhost
DB_PORT=1521
DB_DATABASE=Mydb
DB_USERNAME=db_username
DB_PASSWORD=password
my database.php
'default' => env('DB_CONNECTION', 'sqlsrv'),
...
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'Mydb'),
'username' => env('DB_USERNAME', 'db_username'),
'password' => env('DB_PASSWORD', 'password'),
'charset' => 'utf8',
'prefix' => '',
],
Install Oracle client in your machine: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Install/enable Oracle for PHP. That will depend on your operation system. In windows, I believe you only need to enable on your php.ini, extension=pdo_oci.dll. In linux, you need to install, with apt get or similar in your distro, or recompile PHP with instructions on this page: http://php.net/manual/en/ref.pdo-oci.php
Use this library in your Laravel project: https://github.com/yajra/laravel-oci8
In config/database.php:
'default' => env('DB_CONNECTION', 'my_connection'),
'connections' => [
'my_connection' => [
'driver' => 'oracle',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1521'),
'service_name' => env('DB_SERVICE_NAME', ''),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'options' => [
PDO::ATTR_PERSISTENT => true
],
],
In your .env:
DB_CONNECTION=my_connection
DB_HOST=111.111.111.111
DB_SERVICE_NAME=service
DB_DATABASE=db
DB_USERNAME=user
DB_PASSWORD=pass
It's been around 5-6 hours since I've been trying to use database in laravel 5.
I've gone through of videos and it confused me a lot.
I have created the model and migration but when i try to migrate it gives me an
[ PDOException ] Driver not found
I've made numerous changes to .env and database.php but nothing works.
I am using laravel 5 with xampp server.
Kindly help
Thank you
.env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=zZfvju3BKjxmLKbl5gsVJ3ymkIvHbGNq
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=medicaldb
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
database.php file
<?php
return [
'fetch' => PDO::FETCH_CLASS,
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'medicaldb'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
],
'migrations' => 'migrations',
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];
Finally, at last! it worked!!
In php.ini file:
(semi-colon) ; works as a single-line comment in php.ini file.
(semi-colon) was added at the beginning of the line - which disables pdo mysql driver.
I just needed to remove the semi-colon(;) to enable mysql, from the beginning of the line.
Same problem, ubuntu 17.10, Laravel 5.6
It is the issue normally come when you upgrade you php version I get the same issues in my lammp stack while i update from php 7 to 7.1 I get Solve by following command
Open Terminal
sudo apt install php7.1-pdo php7.1-mysql
Have fun with Code
Are you sure you have mysql intalled? also, please check pdo_mysql module is enabled. use phpinfo();