K
K
Kurusa2018-08-27 00:47:50
MySQL
Kurusa, 2018-08-27 00:47:50

Laravel, database connection issue?

5b83201caa3b8758899753.pngWhen I try to migrate I get the following errors:

In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user 'kurusa_main'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = kurusa_test and table_name = migrations)

In Connector.php line 67:
SQLSTATE[HY000] [1045] Access denied for user 'kurusa_main'@'localhost' (using password: YES)

I am 100% sure that the data for connecting to the database is correct. Tried to run on my server
new PDO('mysql:host=127.0.0.1;dbname=kurusa_test', "kurusa_main", "password");

- successfully.
I don't understand what's wrong. B Connection.php line 664 :
throw new QueryException(
            $query, $this->prepareBindings($bindings), $e
        );

The context of the code is:
protected function runQueryCallback($query, $bindings, Closure $callback)
{
    // To execute the statement, we'll simply call the callback, which will actually
    // run the SQL against the PDO connection. Then we can calculate the time it
    // took to execute and log the query SQL, bindings and time in our memory.
    try {
        $result = $callback($query, $bindings);
    }

    // If an exception occurs when attempting to run a query, we'll format the error
    // message to include the bindings with SQL, which will make this exception a
    // lot more helpful to the developer instead of just the database's errors.
    catch (Exception $e) {
        throw new QueryException(
            $query, $this->prepareBindings($bindings), $e
        );
    }

    return $result;
}

In Connector.php line 67 :
return new PDO($dsn, $username, $password, $options);

Instead, I tried to write my own version:
return new PDO('mysql:host=127.0.0.1;dbname=kurusa_test', "kurusa_main", "password");

Just as unsuccessful.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Ariurn, 2018-08-27
@Ariurn

Try specifying localhost instead of 127.0.0.1.

V
Vyacheslav Barsukov, 2018-08-27
@slavabars

Why are you writing directly? There is also a connection configuration file. And use it.

A
artemmityushov, 2018-08-27
@artemmityushov

Lara works through named connections from .env, that's exactly what happens to you. Read the manual about setting up a database connection. Migrations work exactly through the standard mechanism if you do not use specific connections when describing the migration.
PS No offense, but this is exactly the case as from a joke - And where is the mistake? In DNA.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question