Adonis isn't migrating - mysql-workbench

I've installed mysql npm in my adonis project and also set DB_CONNECTION=mysql in .env.
Everything in my .env is correct, but when i run the migration cmd i get an error.
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage: "Access denied for user 'root'#'172.17.0.1' (using password: YES)",
sqlState: '28000',
fatal: true
I don't have any clue whats going on, i google the error but no solution was found.
And why its saying 'root'#'172.17.0.1' if localhost is 127.0.0.1?
What should i do?

As the error message implies, you're having an authorization problem.
You said that your .env file is correct, but double check if it contains the following variables:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1 //make sure it's your localhost
DB_PORT= //usually 3306
DB_USER=
DB_PASSWORD=
DB_DATABASE=
Then, check if your config/database.js file is properly calling the .env variables, without any typo or missmatched name.
If it is all fine and the problem continues, he i suggest you to check your database credentials.
Try acessing it without password, since some default configurations to mysql databases uses the username root and an empty password. (in the error message you received a (using password: YES))
If you double checked all that and are still getting this error, I recommend you to create another Database User with root privileges.

Related

"Null value for 'password'" - PostgreSQL in DataGrip

I have browsed the web but didn't find any answers/solution to my problem, so i hope somebody here can help me:
I have downloaded DataGrip because i wanted to replace pgAdmin 4. When i try to create a PostgreSQL data source and host it locally, i get the following error: "Null value for 'password'". In pgAdmin 4 i do remember creating a password to access my local database when i first set it up, and it worked fine. However, i don't remember creating a password when installing DataGrip. Is there some default password that im not aware of? And what should be written under "User"?
DataGrip can only connect to the server which already exists (and therefore has a password). "Data source" is the term of DataGrip.
In other words, you need to already have a working database on the server with the known credentials.

Rails spec test error, no password supplied

I have an existing project, with created many years ago. No one at out company has succeeded in running them. I have updated files to fit the latest rails version but when I run bundle exec rspec spec/models/promo_code_spec.rb,
I get
/Users/mmiller/.rvm/gems/ruby-2.1.6#global/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize': fe_sendauth: no password supplied (PG::ConnectionBad)
I have followed these steps in this post:
fe_sendauth: no password supplied
but still getting the same error.
Any advice on how to resolve this issue?
Change this,
local all all trust
to,
local all all md5
and create a super_user in PostgreSQL with username and password, and add that username and password to your database.yml file
Welp, for my case, as a complete new user of Rails testing of any kind, I got this error when I wanted to use RSpec and forgot to create a test database. Make sure your test db has been assigned its own name in database.yml.
One helpful SO post mentioned this command line to get things initialized:
bundle exec rake db:reset RAILS_ENV=test
Then on to joy...

Ansible 2.2 Create Postgresql Database

I am new to ansible (2.2.1) and have started to migrate from our fabric scripts to ansible which I find somewhat better regarding structure. I have run into an issue, it should be pretty straight forward but since I do not know ansible through and through I am not sure how to proceed. I am running this against a vagrant box as of now.
The issue is regarding user privileges and postgres.
Lets say I have this playbook
- hosts: web
become: yes
become_user: root
vars:
dbname: myapp
tasks:
- name: ensure database is created
postgresql_db: name={{dbname}}
I cannot make this simple example work! All dependencies are met. If I do the same thing with mysql this works fine but here I get issues with unable to connect to database: FATAL: Peer authentication failed for user "postgres".
In mysql I use the "root" user with a blank password, which works because I know that user is created upon install with a blank password.
There is a user postgres created when the installation of postgresql is completed so the user exists. And as root I should be able to login by saying I am the postgres user. Am I missing something in how this is done? It works just fine if log into the server and sudo -su postgres && psql.
I also tried to add become_user: postgres by the task I want to run but then I get unprivileged user issues.
Any ideas of what is missing?
Found a few workarounds and a solution, given you are ok with giving away some security (which makes sense, this being an issue just for that reason).
More people having this problem with the new ansible in this github issue thread
https://github.com/ansible/ansible/issues/16048
What I ended up doing was settings allow_world_readable_tmpfiles = True in the ansible.cfg file. Then this is not an issue anymore but you get warnings. I only need this setting for when handling the postgres role, so maybe I'll end up split it up or putting the setting somewhere less global.

Knex:Error Pool2 - error: password authentication failed for user

I am having trouble with my migration to Ubuntu Linux. I can use Postgres in the terminal. So I don't have a problem with the Postgres password.
When I type: knex migrate:latest --env development
I get:
Using environment: development
Knex:warning - Pool2 - Error: Pool was destroyed
Knex:Error Pool2 - error: password authentication failed for user "user"
I've read from other answers in related questions to go into the pg_hba.conf and set the method to trust. I've done this, but no change.
my knex.js file looks like this:
module.exports = {
devolopment: {client: 'pg',
connection: 'postres://localhost/bikesdb'
},
production: {
client: 'pg',
connection: process.env.DATABASE_URL
}
};
I'm not sure what I'm doing wrong.
You are most likely running on node 6.x.x so you'd need to upgrade your pg package version npm install --save pg#4.5.5
Reference: https://github.com/tgriesser/knex/issues/1371
If Andrei Stalbe's solution doesn't help... here are some more thoughts.
How are you connecting to postgres from commandline?
If you are writing just psql bikesdbit actually uses unix socket for connecting and it has different security settings in postgres by default than through TCP. You can try to change your connection string to: postgres:///bikesdb which makes also knex to use unix socket.
You can change/check security policies in pg_hba.conf.
Also you have typo in postres://localhost/bikesdb.
EDIT:
I'm pretty sure you are still having some general postgresql configuration problem. If you like to create user to access your database you can do this:
CREATE ROLE bikesuser WITH LOGIN PASSWORD 'letmepass';
GRANT ALL PRIVILEGES ON DATABASE "bikesdb" TO bikesuser;
And change connection string to:
'postgres://bikesuser:letmepass#localhost/bikesdb'
If you like to allow access from localhost to postgresdb this should do it in pg_hba.conf
host all all 127.0.0.1/32 trust
Hope that something of this is useful, even that it sounds that you have already tried this all.
I had the same problem and it was all about the fact that knex was trying to use the username taken from the environment variables (LOGNAME) of my command line interface.
If Postgres is set to use a different user (by default postgres if you haven't changed it) there will be an authentication error.
You can solve this problem by specifying the authentication credentials inside the URL that you use to connect to the Postgres server.
module.exports = {
devolopment: {client: 'pg',
connection: 'postres://user:password#localhost/bikesdb'
},
production: {
client: 'pg',
connection: process.env.DATABASE_URL
}
};
I highlight the key point in the URL:
postres://user:password#localhost/bikesdb
You can check the name of the user to access the Postgresql server from the UI interface provided by Postgresql and the password is the one that you have defined during the installation phase (if you haven't changed it)
I ran into this problem recently. My issue was I could run migrations on local macOS but not on a remote Linux Ubuntu machine. I found out that the reason was I didn’t have a password set for the user, though everything works fine on local for some reason it required a password on remote (Linux). So, setting password for the user and adding the password to the connection solved my problem.
Example:
On postgres
\password username
Then enter and confirm the password.
In your config file (e.g knexfile.js)
module.export = { client: ‘postgresql`, user: username, password: secret }
I had set my psql to go to my user instead of postgres. However, I reset the postgres password. I just reset the postgres password, and the in the development connection I included the password. (I tried including it before the postgres password reset and it still didn't work). It's odd because the user I specified in the connection was me and not postgres.

Error connecting to PGSQL database in Joomla

I am trying to install Joomla using Postgres and in the installer I have the following error:
Could not connect to the database. Connector returned number: Error connecting to PGSQL database.
This isn't telling me very much. Any ideas?
Unfortunately the installer does not return the real error.
Here are some general tips:
make sure the provided database already exists
check if your database needs some specific settings, such as a different port or sslmode=require
Put your connection details in a normal php file and run the script, having error reporting enabled:
<?php
$connection = 'host=127.0.0.1 port=5432 dbname=joomla3 user=postgres password=postgres';
$dbconn = pg_connect($connection);
var_dump($dbconn);
When running the script you might get a proper error. When you get a resource, the connection is successful: resource(4) of type (pgsql link)
Check selinux configuration:
$ sudo setenforce Permissive
and try again. If it works you can disable selinux at /etc/selinux/config and change the line
SELINUX=enforcing
by
SELINUX=permissive