Issue on baking process on linux (terminal)

please help me…
i am a beginner with cakephp3,
i am facing issue with bake in cakephp 3 on linux , i have following issue at the time of enter following line on terminal (linux) " bin/cake bake all users "

mysystems:/opt/lampp/htdocs/myapps$ bin/cake bake all users

i have getting following error message on terminal (linux)

Welcome to CakePHP v3.3.15 Console
App : src
Path: /opt/lampp/htdocs/myapps/src/
PHP : 5.5.9-1ubuntu4.21
Bake All

One moment while associations are detected.
Exception: SQLSTATE[28000] [1045] Access denied for user ‘root’@‘localhost’ (using password: NO) in [/opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php, line 48]
2017-04-03 12:33:07 Error: [PDOException] SQLSTATE[28000] [1045] Access denied for user ‘root’@‘localhost’ (using password: NO)
Stack Trace:
#0 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php(48): PDO->__construct(‘mysql:host=loca…’, ‘root’, ‘’, Array)
#1 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php(104): Cake\Database\Driver\Mysql->_connect(‘mysql:host=loca…’, Array)
#2 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Schema/BaseSchema.php(45): Cake\Database\Driver\Mysql->connect()
#3 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Dialect/MysqlDialectTrait.php(63): Cake\Database\Schema\BaseSchema->__construct(Object(Cake\Database\Driver\Mysql))
#4 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Schema/Collection.php(52): Cake\Database\Driver\Mysql->schemaDialect()
#5 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(42): Cake\Database\Schema\Collection->__construct(Object(Cake\Database\Connection))
#6 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Database/Connection.php(322): Cake\Database\Schema\CachedCollection->__construct(Object(Cake\Database\Connection), true)
#7 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(951): Cake\Database\Connection->schemaCollection()
#8 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(903): Bake\Shell\Task\ModelTask->_getAllTables()
#9 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(207): Bake\Shell\Task\ModelTask->listAll()
#10 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(127): Bake\Shell\Task\ModelTask->getAssociations(Object(Cake\ORM\Table))
#11 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(110): Bake\Shell\Task\ModelTask->getTableContext(Object(Cake\ORM\Table), ‘users’, ‘Users’)
#12 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(97): Bake\Shell\Task\ModelTask->bake(‘Users’)
#13 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/BakeShell.php(257): Bake\Shell\Task\ModelTask->main(‘Users’)
#14 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Collection/CollectionTrait.php(52): Bake\Shell\BakeShell->Bake\Shell{closure}(‘users’, 0)
#15 /opt/lampp/htdocs/myapps/vendor/cakephp/bake/src/Shell/BakeShell.php(260): Cake\Collection\Collection->each(Object(Closure))
#16 [internal function]: Bake\Shell\BakeShell->all(‘users’)
#17 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Console/Shell.php(458): call_user_func_array(Array, Array)
#18 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(227): Cake\Console\Shell->runCommand(Array, true, Array)
#19 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(182): Cake\Console\ShellDispatcher->_dispatch(Array)
#20 /opt/lampp/htdocs/myapps/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(128): Cake\Console\ShellDispatcher->dispatch(Array)
#21 /opt/lampp/htdocs/myapps/bin/cake.php(34): Cake\Console\ShellDispatcher::run(Array)
#22 {main}

Thank you

Try bin/cake server and see the output, probably you haven’t configured Datasources properly in app.php.

thank for your feedback Gaurav,

but i have configured my database inside my folder structure
which is look like this

app.php -

‘Datasources’ => [
‘default’ => [
‘className’ => ‘Cake\Database\Connection’,
‘driver’ => ‘Cake\Database\Driver\Mysql’,
‘persistent’ => false,
‘host’ => ‘localhost’,
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
//‘port’ => ‘non_standard_port_number’,
‘username’ => ‘root’,
‘password’ => ‘’,
‘database’ => ‘cake_php’,
‘encoding’ => ‘utf8’,
‘timezone’ => ‘UTC’,
‘flags’ => [],
‘cacheMetadata’ => true,
‘log’ => false,

thank you

I have not much idea about LAMP apllication but try to connect MySQL from terminal using mysql -u root -p and see what you get if you are able to login without any password then you have check your LAMP.

Hi Gaurav, thank you for reply

i did as per your guidance in terminal and i have getting following message “using without password”

ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)

thank you

This means i am not able to login without password

So this means you have the wrong configuration in app.php. If you remember the MySQL password then set it or re-install MySQL.

ok thank you i will try…!

Hi ,
I m facing issue last night as below.

Argument 1 passed to Cake\ORM\Table::save() must implement interface Cake\Datasource\EntityInterface, array given, called in /opt/lampp/htdocs/billingcake/src/Controller/BillsController.php on line 48

My code is,

<?php namespace App\Controller; use App\Controller\AppController; use Cake\ORM\Table; use Cake\Event\Event; use Cake\ORM\Query; use Cake\ORM\TableRegistry; use Cake\Routing\Router; use App\Model\Entity\Role; use Cake\Datasource\ConnectionManager; use Cake\View\Helper\HtmlHelper; use Cake\View\View; use Cake\Core\Configure; use Cake\Network\Exception\ForbiddenException; use Cake\Network\Exception\NotFoundException; use Cake\View\Exception\MissingTemplateException; use Cake\Collection\Collection; use Faker; class BillsController extends AppController { public function initialize() { parent::initialize(); $this->loadComponent('RequestHandler'); } public function index(){ $bill = $this->Bills->newEntity(); if ($this->request->is('post')) { $bill = $this->Bills->patchEntity($bill, $this->request->data); $bill = $this->request->data('product_id'); $products = TableRegistry::get('Products'); $query = $products->find('list'); $bill = $query->toArray(); if ($this->Bills->save($bill)) { $this->Flash->success(__('The billNo has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The billNo could not be saved. Please, try again.')); } $this->set(compact('bill')); $this->set('_serialize', ['bill']); } } ?>

Try to understand this part, you are doing wrong over here. Btw the original issue is different from yours so create a new one that will be a good idea.

Thanx for your reply,

I want to achieve from one table record insert into another table (db). I have created one field for product name and i want to get the product_id of particular product.
I want matched the inserted product name which is equal to matched the product like as below

$_POST[‘productname’] = $productname;

$sel_query = "SELECT * FROM PRODUCT_TABLE WHRER producname=$productname ";
$sql_query = mysqli_query($conn,$sel_query);
$row = mysqli_fetch_assoc($sql_query);
$product_id = $row[‘ID’];

Sir, I want to make a above php code into cakephp 3 code…
so how can i achieve this plz help me.

Sorry, but this doesn’t make any sense to me. If you are trying to set any field to any entity just use that in object format something like $bill->product_id = $productId.


How to upload my cakephp3.4 project on online server using file zila ?Please help me sir

Please go to the Larry Page. Also If you are asking some question which is not related to the current issue, then create a new issue don’t start with some random topics.
Join the channels for easy or quick questions. Btw what you are asking is not an issue!