psql: FATAL: Ident authentication failed for user "root" - php

Hi i am using postgresql .
my
Postgres User : postgres
Passwprd : abc123
but when i type root#xxxx:~#psql -U postgres -W
it says
root#xxxx:~# Ident authentication failed for user "root"
but when i su postgres cd and then type following command
#psql -U postgres -W
it is working correctly and i can access to all databases .
when i try to access my site it gives me the error in posstgres error log
password authentication failed for user "postgres"
why is this happening , please help me , thanks in advance
UPDATE
my pg_hba.conf
# Database administrative login by Unix domain socket
local all postgres trust
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 md5

You have to create a role name root
create role root login

Related

Mysql cannot login from user account

From root user, I can execute this command without any problems:
[root#freebsd ~/var/html/www]$ bin/console d:run-sql 'SELECT * from user';
From www user, I cannot execute this command:
[www#freebsd ~/var/html/www]$ bin/console d:run-sql 'SELECT * from user';
because I am getting the following error:
An exception occurred in driver: SQLSTATE[HY000] [2002] Permission denied
Both users are using the same config file:
parameters:
database_driver: "pdo_mysql"
database_url: "mysql://dbuser:dbuserpass#127.0.0.1:3306/dbname"
I am using MariaDB 10.4 which is running on Freebsd with PHP(Symfony project)
Authentication problems comes with an access denied message.
A permission denied error means that you authentication happened but the resource you're trying to access was denied. Probably the dbname database.
You need to grant at least a "select" permission to this user with root or another administrator user:
GRANT SELECT ON dbname.* TO dbuser#127.0.0.1;
Pay attention because with mysql client if we don't specify a host or specify it like localhost instead of 127.0.0.1, the client tries to connect trought unix socket.
You can overcome this with --protocol tcp or using a IP address.

MySQL8 connection with php7.3 and Symfony 5 does not work

I have a connection problem with a mysql8 database, php7.3 and Symfony 5. The user and the password are correct !
The connection to MySQL8 database must be done from an SSH tunnel
The SSH tunnel is working :
ssh -p [remote_machine_port] -N -L [mysql_tunnel_port]: 127.0.0.1: 3306 -i / [directory] / private_key [username] # [remote_machine_ip]
MySQL access configuration:
GRANT ALL PRIVILEGES ON 'databasename'.* TO '[user]'#'%' WITH GRANT OPTION;
Doctrine configuration :
DATABASE_URL='mysql://[user]:[password]#127.0.0.1:[port_tunnel_mysql]/[databasename]'
An exception occurred in driver: SQLSTATE [HY000] [1130] Host '127.0.0.1' is not allowed to connect to this MySQL server
I have the same problem with heidiSQL and on the VM
I tried with the Ip of the VM instead of 127.0.0.1
ssh -p [port_machine_distant] -N -L [port_tunnel_mysql]:[ip_machine_vm]:3306 -i /[directory]/private_key [username]#[ip_machine_distant]
Doctrine configuration
DATABASE_URL='mysql://[user]:[password]#[ip_machine_vm]:[port_tunnel_mysql]/[databasename]'
An exception occurred in driver: SQLSTATE [HY000] [2002] Connection refused
However, this setting works with heidiSQL but not with the Symfony application !
Did I forget a setting on the VM or Mysql ?
127.0.0.1 connection issue :
We have created the '[user]'#'127.0.0.1' rights.
In MySQL, 127.0.0.1 uses the network and localhost uses the socket.
The message "The server requested authentication method unknown to the client [caching_sha2_password]" was caused because the setting 'default-authentication-plugin=mysql_native_password' was created after the creation of the rights.
We regenerated the rights, and now everything is working fine.

How to take backup of amazon database(mysql)

I want to take backup of database from amazon by using linux command .
I am trying for
mysqldump --databases mydbname -v -h XXXXX.XXXXXX.us-west-2.rds.amazonaws.com -u username -P 3306 -p > mydbname.sql
But it gives the error
mysqldump: Got error: 1045: Access denied for user 'username'#'125.94.62.234' (using password: YES) when trying to connect
Please help me out
First of all you need to add your ip address in AWS security group
you can check your ip address by type in google "what is my ip".
TO add in AWS - you need to login in your AWS site
GOTO EC2 services
then goto - Security groups under Network / security
check your used security group and then click into inbound rule
Add new rule
Select Mysql Aurora / TCP / 3306 / Custom IP / your ip address.
After doing all this you can use below command
mysqldump -u -p -h databasename > backup.sql
hope this can help you

Postgress and PHP "Ident authentication failed for user"

On my local server (Ubuntu 14.04) all work ok. But on test server (Centos) i cannot connect from PHP (Yii 1.1) to my database.
On both servers i used same dump, user name, password, postgres and php code versions.
On local server apache. On Test nginx.
CDbConnection failed to open the DB connection: SQLSTATE[08006] [7]
FATAL: Ident authentication failed for user "tripinsu"
pg_hba.conf:
local all all md5
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
I fixed. Not sure what i changed. I just copy my correct config from ubuntu.
local all postgres peer
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
I hope this help somebody else

Accessing mysql dbase with MysqlWorkBench on VirtualBox (Vagrant - ZF - BoilerPLate)

Does anyone know hot to connect to VB MySQL via MysqlWorkBench. I can log in in virtual box via terminal, but I can not connect it throught MySqlWorkBench. Also I can ping google on vb, ifconfig gave me 10.0.2.15 address, and when I enter it in MysqlWorkBench I got error:
Failed to Connect to MySQL at 127.0.0.1:3306 through SSH tunnel at 10.0.2.15:2222 with user davs
My Virtual box use port 2222 for connecting. Also when I try to connect with ip 127.0.0.1
Failed to Connect to MySQL at 127.0.0.1:3306 through SSH tunnel at 127.0.0.1:2222 with user davs Failed to Connect to MySQL at 127.0.0.1:3306 through SSH tunnel at 127.0.0.1:2222 with user davs
Any advice will be helpfull, thanks.
This looks like an old question but since I just ran into the problem, here are the settings that I used on MysqlWorkbench to get everything working on my mac:
Connection Method: Standard TCP/IP over SSH
SSH Hostname: 127.0.0.1:2222
SSH Key File: /Users//.vagrant.d/insecure_private_key
Mysql Hostname: 127.0.0.1
Mysql Server Port: 3306
Username: root
Password: vagrant
Your settings may be slightly different but the key part is using the insecure private key as was mentioned earlier.
Use the 'insecure private key' located at: ~/.vagrant.d/insecure_private_key

Categories