0
I’m getting a permission error to create the Huge Login:
Fatal error: Uncaught Exception 'Pdoexception' with message 'SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost (using password: YES) ' in /var/www/html/myproject/application/core/Databasefactory.php on line 42
( ! ) Pdoexception: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES) in /var/www/html/myproject/application/core/Databasefactory.php on line 42
Following some responses from Soen as this, I’ve already changed the permissions of the application and folder folders tmp
for -R 777
, I changed the root password, etc, but nothing did not solve.
The archive DatabaseFactory.php
:
<?php
class DatabaseFactory
{
private static $factory;
private $database;
public static function getFactory()
{
if (!self::$factory) {
self::$factory = new DatabaseFactory();
}
return self::$factory;
}
public function getConnection() {
if (!$this->database) {
$options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
$this->database = new PDO(
Config::get('DB_TYPE') . ':host=' . Config::get('DB_HOST') . ';dbname=' .
Config::get('DB_NAME') . ';port=' . Config::get('DB_PORT') . ';charset=' . Config::get('DB_CHARSET'),
Config::get('DB_USER'), Config::get('DB_PASS'), $options
);
}
return $this->database; // ->>> linha 42
}
}
The BD configuration data:
'DB_TYPE' => 'mysql',
'DB_HOST' => '127.0.0.1',
'DB_NAME' => 'huge',
'DB_USER' => 'root',
'DB_PASS' => 'password',
'DB_PORT' => '3306',
'DB_CHARSET' => 'utf8',
The privileges of the comic book huge
:
System:
Server: Localhost via UNIX socket
Type of server: Mysql
Server version: 5.5.44-0ubuntu0.14.04.1 - (Ubuntu)
Version of the protocol: 10
User: root@localhost
Server charset: UTF-8 Unicode (utf8)
(on the last line I deleted the name of my maq. for security...)
Any idea?
Try to change
localhost
for127.0.0.1
.– Rodrigo Rigotti
@Rodrigorigotti In the BD access configuration (in the framework) I’m already using
127.0.0.1
( and in browser tbm), but the error keeps popping up root@localhost. There are some other files that need to change this?– gustavox
Puts the version of your mysql. The database is on the same machine that you are working on(ie the access does not come from a remote machine)?
– rray
I don’t know how it works in the framework you’re using, but try changing the connection string directly to make a test.
– Rodrigo Rigotti
Got it, the error in my view seems more like a definition of access to the database, you have correctly defined this data in your config?
Config::get('DB_USER')
andConfig::get('DB_PASS')
– Ivan Ferrer
If you’re using Doctrine, try deleting the cache.
– Ivan Ferrer
Give an echo on that connected STRING because the problem is it for sure. because if Voce puts 127.0.0.1 and it does not change in the error... it is taking standard connection string!
– Danilo Breda
@rray the database is on the same machine yes. mysql is 5.5.44 (I edited the question with the system data)...
– gustavox
Give it an echo:
Config::get('DB_TYPE') . ':host=' . Config::get('DB_HOST') . ';dbname=' .
 Config::get('DB_NAME') . ';port=' . Config::get('DB_PORT') . ';charset=' . Config::get('DB_CHARSET'),
 Config::get('DB_USER'), Config::get('DB_PASS')
; die(); and see what happens.– Ivan Ferrer
@Daniloloko think I expressed myself badly. It does not change the error... even if I put 127.0.0.1, it gives write in error
Access denied for user 'root'@'localhost'
– gustavox
I looked at the OS link you suggested in the question, you tried to solve thus ?
– rray
@rray followed this answer now but did not resolve... was looking at the other answers (nice btw link), and trying to follow that one, got the bug
$ sudo mysql -h localhost -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
– gustavox
So, I don’t know if it’s your problem ... with the newer versions of mysql I had trouble creating a password for root, said the generated hash was too short ... if I find the link send you. Try logging in via command line and changing the root password. Do not include the
-p
– rray
Okay @rray, I’ll try here. Thanks! PS: One detail is that only with Huge login does not access db, when I want to write to the database without using the framework, (by connecting directly through a form page for example) works normally...
– gustavox
Ah, I found out what it was. It’s just that I installed it in a directory, and then I just copied the vendor folder in the directory that I had already created before (thinking that I didn’t need the whole content of the installation within the project), so it was going to get the password in the installation directory. Then I changed the password there and got good. Thanks to all who tried to help! I’m going to indicate this question as a duplicate of the one @rray indicated... thanks anyway. Hugs.
– gustavox