We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)

Project BLOG

Hi Guys,

I am following the video Project Blog, but on the earlier coding and testing - I got the error SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO). I tried to search for a fixed but I was not successfull.

My app/config/config.php was set.

'database' => array(
    'adapter'     => 'Mysql',
    'host'        => 'localhost',
    'username'    => 'blog',
    'password'    => 'WpEuhpjEsaFuV9eJ',
    'dbname'      => 'blog',
    'charset'     => 'utf8',

I run the phalcon model polls to create the model and it was successfull. Please see below.

# phalcon model polls
Phalcon DevTools (2.0.1)
Success: Model "polls" was successfully created. 

My app/controller/PollController.php

public function indexAction() {
   $this->view->polls = Polls::find();

My app/models/Polls.php (still no change)

// @var integer
public $id;

// @var string
public $question;

public function columnMap()
    return array(
        'id' => 'id', 
        'question' => 'question'

My app/views/poll/index.volt, is just a single liner.



Coud you upload file config.php ?


Hi Thien,

Please see: config.php.

Same as script below:

return new \Phalcon\Config(array(
  'database' => array(
      'adapter'     => 'Mysql',
      'host'        => 'localhost',
      'username'    => 'blog',
      'password'    => 'WpEuhpjEsaFuV9eJ',
      'dbname'      => 'blog',
      'charset'     => 'utf8',
  'application' => array(
      'controllersDir' => __DIR__ . '/../../app/controllers/',
      'modelsDir'      => __DIR__ . '/../../app/models/',
      'migrationsDir'  => __DIR__ . '/../../app/migrations/',
      'viewsDir'       => __DIR__ . '/../../app/views/',
      'pluginsDir'     => __DIR__ . '/../../app/plugins/',
      'libraryDir'     => __DIR__ . '/../../app/library/',
      'cacheDir'       => __DIR__ . '/../../app/cache/',
      'baseUri'        => '/blog/',



I see file service.php https://github.com/enasr/phalcon-blog/blob/master/blog/app/config/services.php#L56 maybe wron, tried this

 * Database connection is created based in the parameters defined in the configuration file
$di->set('db', function () use ($config) {
    return new DbAdapter($config->database->toArray());

But recommed setting like

    function () use ($config) {
        return new DbAdapter([
            'host'     => $config->database->mysql->host,
            'username' => $config>database->mysql->username,
            'password' => $config->database->mysql->password,
            'dbname'   => $config->database->mysql->dbname,
            'options'  => array(
                \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $config->database->mysql->charset
    true // shared


Thanks again Thien,

Still I got this error SQLSTATE[HY000] [2002] No such file or directory


Though I tried to apply some fixes editing my php.ini

with pdo_mysql.default_socket=


mysql.default_socket =

mysql.default_socket = /var/lib/mysql/mysql.sock

mysqli.default_socket =

mysqli.default_socket = /var/lib/mysql/mysql.sock

Still I got this error SQLSTATE[HY000] [2002] No such file or directory


Hi Guys,

Any ideas to fix this issue? I am not sure where did I miss a process, is it during the installation of the PHALCON?

For more info: I am using fedoraLinux21 and can only use phalcon command via root. if not root im having a bash: command not found.

Need help and looking forward to fly with phalcon.



Are you sure the mysql running. I'm use Fedora 21 and working fine


Hi Thien,

Yeap, the model was successfully created, I can access mysql via cli and via phpmyadmin, I am very sure that mysql is running, I checked also the status and it is live.


Hi Thien,

Below is my mysql status result. Am I using the correct mysql server? Please advise.

# service mysqld status
Redirecting to /bin/systemctl status  mysqld.service
‚óŹ mysqld.service - MySQL compatibility service (another name for mariadb.service; you should use mariadb.service instead)
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
   Active: active (exited) since Wed 2015-05-27 18:11:55 PHT; 29s ago
  Process: 5871 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 5871 (code=exited, status=0/SUCCESS)


Hi Guys,

I searched on the installation and found and article showing the phalcon info and it looks like below:

but mine shows no directive like phalcon.db.escape_identifiers, phalcon.orm.column.remaining, etc....

It only shows:


Web framework delivered as a C-extension for PHP

phalcon enabled
Author Phalcon Team and contributors
Version 2.0.2
Powered by Zephir Version 0.6.3a

under this table is Phar library and its directive.

Need help...


Hi Thien and Others,

Thanks and I am sorry to brought up this issue. My phalcon now is working.

What I did was uninstall/delete all phalcon files. I tried to do some reinstallation of phalcon and devtools from the start and tried to create the blog project and tested it - now it works with no error showing as earlier mention.

It is great that the team phalcon's are willing to support each other.

Now I'll to do some more codings. You can tag this now as solved!

Have a great fying with phalcon...


Cheer, We have glad hear that, anyway you can checkout tip and trick Phalcon here https://phalcontip.com

Hi, I had same problem and i found that changing from: return new DbAdapter($config->database->toArray()); to return new DbAdapter($config["database"]->toArray()); fixes problem ;-)