database.default.dsn not working |
hello, I am trying to connect to postresql using the dsn parameter for the default database schema
I have confirmed the pdo_pgsql is enabled in phpinfo, ultimately I need to be able to add sslverify to the dsn string to make an SSL only connection to the postgresql database here is my dsn - no connection, does not work database.default.dsn ='pgsql:host=xx.xx.xx.xx;port=5432;dbname=xx;username=xxx;password=xxxx;sslmode=verify-ca;sslrootcert=/ssl/db/server-ca.pem;sslcert=/ssl/db/client-cert.pem;sslkey=/ssl/db/client-key.pem' #database.default.hostname = ip #database.default.database = dbname #database.default.username = dbuser #database.default.password = dbpass #database.default.DBDriver = Postgre #database.default.port = 5432 #database.default.schema = public if I un comment the below - this works #database.default.dsn ='pgsql:host=xx.xx.xx.xx;port=5432;dbname=xx;username=xxx;password=xxxx' database.default.hostname = ip database.default.database = dbname database.default.username = dbuser database.default.password = dbpass database.default.DBDriver = Postgre database.default.port = 5432 I have been referencing the following database configuration page on codeigniter user guide https://codeigniter.com/user_guide/datab...h-env-file any help or guidance would be greatly appreciated
CI4 does not use the PDO driver.
To use a DSN for CI drivers, the string must follow the format: DBDriver://username:password@hostname:port/database But in your case, your DSN should work specifying the driver through a property. database.default.DBDriver = Postgre (02-05-2022, 11:29 AM)iRedds Wrote: CI4 does not use the PDO driver. Thank for you for the response. I am able to successfully connect to the database with mysql or postgre the issue comes when I want to use an SSL connection, it does not work. I can connect using the command line and the certificates but not through the .env file or the database.php file
Try to create a database connection.
PHP Code: pg_connect('host=xx.xx.xx.xx port=5432 dbname=xx username=xxx password=xxxx sslmode=verify-ca sslrootcert=/ssl/db/server-ca.pem sslcert=/ssl/db/client-cert.pem sslkey=/ssl/db/client-key.pem'); If the connection failed or without SSL, then you can not read further. If the connection succeeded. PHP Code: database.default.DSN ='pgsql:host=xx.xx.xx.xx;port=5432;dbname=xx;username=xxx;password=xxxx;sslmode=verify-ca;sslrootcert=/ssl/db/server-ca.pem;sslcert=/ssl/db/client-cert.pem;sslkey=/ssl/db/client-key.pem'
thank you very much for your help.
The below finally worked in the .env file database.default.DSN = 'pgsql:host=xx.xx.xx.xx;port=5432;dbname=xxx;user=xxx;password=xxxx;sslmode=verify-ca;sslrootcert=/ssl/db/pg_server-ca.pem;sslcert=/ssl/db/pg_client-cert.pem;sslkey=/ssl/db/pg_client-key.pem' database.default.DBDriver = Postgre Note username is not a valid parameter, it is user https://www.php.net/manual/en/function.pg-connect.php
|
Welcome Guest, Not a member yet? Register Sign In |