I'm having trouble connecting to a dataase with the following error:
Could not connect to the database.
Please check the config file.
I have tried changing the $_DVWA[ 'db_server' ] to 'localhost' but that didn't work and I tried chainging $_DVWA[ 'db_port '] to 3306, but that didn't work either. The password is empty.
The config file looks like this:
<?php
# If you are having problems connecting to the MySQL database and all of the variables below are correct
# try changing the 'db_server' variable from localhost to 127.0.0.1. Fixes a problem due to sockets.
# Thanks to #digininja for the fix.
# Database management system to use
$DBMS = 'MySQL';
#$DBMS = 'PGSQL'; // Currently disabled
# Database variables
# WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
# Please use a database dedicated to DVWA.
$_DVWA = array();
$_DVWA[ 'db_server' ] = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ] = 'root';
$_DVWA[ 'db_password' ] = '';
# Only used with PostgreSQL/PGSQL database selection.
$_DVWA[ 'db_port '] = '5432';
#this can be 3306 or 5432
# ReCAPTCHA settings
# Used for the 'Insecure CAPTCHA' module
# You'll need to generate your own keys at: https://www.google.com/recaptcha/admin/create
$_DVWA[ 'recaptcha_public_key' ] = '(did not want to disclose this)';
$_DVWA[ 'recaptcha_private_key' ] = '(did not want to disclose this)';
# Default security level
# Default value for the secuirty level with each session.
# The default is 'impossible'. You may wish to set this to either 'low', 'medium', 'high' or impossible'.
$_DVWA[ 'default_security_level' ] = 'impossible';
# Default PHPIDS status
# PHPIDS status with each session.
# The default is 'disabled'. You can set this to be either 'enabled' or 'disabled'.
$_DVWA[ 'default_phpids_level' ] = 'disabled';
# Verbose PHPIDS messages
# Enabling this will show why the WAF blocked the request on the blocked request.
# The default is 'disabled'. You can set this to be either 'true' or 'false'.
$_DVWA[ 'default_phpids_verbose' ] = 'false';
?>
Any suggestions?
$_DVWA['db_server'] = '127.0.0.1:3306'; (Or the port that you use)
Related
I've installed Moodle with Postgres. The db configuration looks like (yeah, I did it in a bit hackish way):
$CFG->dbtype = 'pgsql'; // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = "my-moodle-db.net' connect_timeout=10 sslmode=verify-full sslrootcert='/path/to/cas/allCAs.pem"; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = $pwd_name; // database name, eg moodle
$CFG->dbuser = 'moodle'; // your database username
$CFG->dbpass = $pwd_pwd; // your database password
$CFG->prefix = 'mdl_'; // prefix to use for all table names
$CFG->dboptions = array(
'dbpersist' => true, // should persistent database connections be
...
My installation works almost fine but once in roughly 10 requests I'm getting the following error:
Error: Database connection failed
And the page is rendered immediately though I set connection timeout to 10 above.
Is there any other place to fix connection timeouts in PHP?
Can I make moodle somehow retry the connection before returning the error to me?
I'm trying to use Google Cloud SQL over SSL from GCE(Google Compute Engine) instance. My problem is that I cannot connect to Cloud SQL instance over SSL.
mysql command works normally. I can connect to Cloud SQL instance with certification files.
mysql -uroot -p -h [IP Address] --ssl-ca=/home/user/.cert/server-ca.pem --ssl-cert=/home/user/.cert/client-cert.pem --ssl-key=/home/user/.cert/client-key.pem
However, I got warning and fatal error as followings when I access from PHP program.
<?php
$pdo = new PDO('mysql:host=[IP Address];dbname=testdb', 'root', 'test', array(
PDO::MYSQL_ATTR_SSL_KEY =>'/home/user/.cert/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT=>'/home/user/.cert/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA =>'/home/user/.cert/server-ca.pem'
)
);
$stmt = $pdo->query("SHOW TABLES;");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($row);
?>
PHP Warning: PDO::__construct(): Peer certificate CN=`[GCP project name]:[Cloud SQL instance name]' did not match expected CN=`[IP Address]' in /tmp/mysql.php on line 7
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] ' in /tmp/mysql.php on line 7
I got same error when I used mysqli.
$mysqli = mysqli_init();
mysqli_options($mysqli, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
$mysqli->ssl_set('/home/user/.cert/client-key.pem',
'/home/user/.cert/client-cert.pem',
'/home/user/.cert/server-ca.pem',
NULL,NULL);
$mysqli->real_connect('[IP Address]', 'root', 'test', 'testdb', 3306, NULL, MYSQLI_CLIENT_SSL);
PHP Warning: mysqli::real_connect(): Peer certificate CN=`[GCP project name]:[Cloud SQL instance name]' did not match expected CN=`[IP Address]' in /tmp/mysql3.php on line 30
Warning: mysqli::real_connect(): (HY000/2002): in /tmp/mysql3.php on line 30
This question looks be relevant to my case but there is no answer yet. SSL self-signed certifications to connect with Mysql with PHP
Does anyone know about solutions?
Update 1
The bug is reported. https://bugs.php.net/bug.php?id=71003
Very similar question here. Google Cloud SQL SSL fails peer certificate validation
My PHP version is 5.6.14. I will update to 5.6.16 to use MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT.
Update 2
Fixed it when I use mysqli
What I did are as followings:
1 I updated my PHP to 5.6.20
sudo apt-get install php5
2 I put the MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT option like this.
$mysqli->real_connect('[IP Address]', 'root', 'test', 'testdb', 3306, NULL, MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
My application uses both mysqli and PDO for some reasons. I'm now looking for PDO's solution.
Update 3
This bug report shows about PDO's case. Sounds not fixed yet.
https://bugs.php.net/bug.php?id=71845
This is also related. https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/google-cloud-sql-discuss/4HNvmq7MpU4/kuSjhkS2AwAJ
As far as I understand, there is no way to resolve for PDO.
Update 4
Some people blame google's design of CN names (I agree with them actually..)
What's worst is you guys use impossible CN names (:) . If the CN was without colon maybe I can map the ip and the CN in my hosts file so that when peer validation is done it can pass. With the colon, php thinks is host and is port
and Google's staff? understand the problem.
I understand the current situation when connecting by IP is not ideal.
But it seems they provide a solution called 'proxy'.
https://groups.google.com/forum/#!topic/google-cloud-sql-discuss/gAzsuCzPlaU
I'm using Cloud SQL second generation and my applications are hosted GCE. So I think I can use the proxy way. I will try it now.
Update 5
Setup the proxy access. Solved both PDO and mysqli access.
Install the proxy on Ubuntu
$ wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64
$ mv cloud_sql_proxy.linux.amd64 cloud_sql_proxy
$ chmod +x cloud_sql_proxy
$ sudo mkdir /cloudsql; sudo chmod 777 /cloudsql
$ ./cloud_sql_proxy -dir=/cloudsql -instances=<project name>:us-central1:mydb
PDO
<?php
$pdo = new pdo('mysql:unix_socket=/cloudsql/<project name>:us-central1:mydb;dbname=testdb','root','test');
$stmt = $pdo->query("SHOW TABLES;");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($row);
?>
mysqli
$mysqli = mysqli_connect('localhost', 'root', 'test', 'testdb', 3306, '/cloudsql/<project name>:us-central1');
$sql = "SELECT id FROM users";
if ($result = $mysqli->query($sql)) {
while ($row = $result->fetch_assoc()) {
echo $row["id"] . "\n";
}
$result->close();
}
$mysqli->close();
refs (Japanese)
http://blog.hrendoh.com/connecting-to-google-cloud-sql-using-mysql-client/
http://blog.hrendoh.com/google-appengine-php-using-cloud-sql/
For PDO connections that don't use Google cloud or cannot benefit from the proxy solution, they have fixed the bug and it is merged now.
There is now a constant for this (starting April 2017):
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
http://git.php.net/?p=php-src.git;a=commit;h=247ce052cd0fc7d0d8ea1a0e7ea2075e9601766a
In short, use Cloud SQL Proxy if you need to access from both PDO and mysqli. You have no choice.
https://cloud.google.com/sql/docs/sql-proxy
For mysqli, adding:
MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT
to real_connect() solved my instance of this issue.
Example (replace host, user, password and database as needed):
$db_connection->real_connect('ip address or host', 'user', 'password', 'database', 3306, NULL, MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
Full php mysqli SSL connection script:
// check if openssl is enabled on server
if(!extension_loaded('openssl')) {
throw new Exception('This app needs the Open SSL PHP extension and it is missing.');
}
// start connection
$db_connection = mysqli_init();
// set ssl config (update with your certs location)
$db_connection->ssl_set('/etc/my.cnf.d/certs/client-key.pem','/etc/my.cnf.d/certs/client-cert.pem', '/etc/my.cnf.d/certs/ca-cert.pem', NULL, NULL);
// connect (update with your host, db and credentials)
$db_connection->real_connect('ip address or host', 'user', 'password', 'database', 3306, NULL, MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
Example in CakePHP 3.5.x + PHP 7.1.x + SQL Google Cloud + SSL
Change file in: config/app.php
...
...
/**
* The test connection is used during the test suite.
*/
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'xx.xxx.xxx.xxx',
//'port' => 'non_standard_port_number',
'username' => 'user_name_x',
'password' => 'pass_x',
'database' => 'bd_name_x',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
'log' => false,
'flags' => [
PDO::MYSQL_ATTR_SSL_KEY => CONFIG.'client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => CONFIG.'client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA => CONFIG.'server-ca.pem',
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
],
//'ssl_key' => CONFIG.'client-key.pem',
//'ssl_cert' => CONFIG.'client-cert.pem',
//'ssl_ca' => CONFIG.'server-ca.pem',
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
],
],
...
...
Example PHP Pure + PDO + SSL:
$ssl_key = CONFIG.'client-key.pem';
$ssl_cert = CONFIG.'client-cert.pem';
$ssl_ca = CONFIG.'server-ca.pem';
$pdo = new PDO('mysql:host=xxx.xxx.xxx.xxx;dbname=db_name_x', 'user_name_x', 'pass_x', array(
PDO::MYSQL_ATTR_SSL_KEY => '/path/full/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => '/path/full/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA => '/path/full/server-ca.pem',
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
)
);
$statement = $pdo->query("SHOW TABLES;");
var_dump($statement);
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo json_encode($row);
exit();
I had the same problem with a MySQL database hosted at compose cluster.
After searching and testing for hours, I found out that the best solution is to disable testing the certificate provided by the server by using the MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag.
I haven't tested it with PDO but with the mysqli interface it is working for me.
In general this problem would appear with a database hosted at a cluster server.
I get this error always
Server is unwilling to perform
and my code is the next:
echo "Checking ...";
$username = $_POST["username"];
$passwd = $_POST["passwd"];
$host = 'myhost.co.uk';
$port = 389;
$dn = 'uid='.$username.',cn=nssproxy,ou=users,dc=co,dc=uk';
// conexion a ldap
$conn = ldap_connect( "ldap://".$host.":389") ;
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
// match de usuario y password
$bind = ldap_bind( $conn, $dn, $password );
if ($bind){
echo "OK";
}
else {
echo "NO OK";
}
echo ldap_error($conn);
Why I have this error? I'm always testing with any user, this script return same error.
Thanks in advance.
So I searched Google for Server is unwilling to performand the first result says:
C.1.4. ldap_*: server is unwilling to perform
slapd will return an unwilling to perform error if the backend holding the target entry does not support the given operation.
The password backend is only willing to perform searches. It will return an unwilling to perform error for all other operations.
The shell backend is configurable and may support a limited subset of operations. Check for other errors indicating a shortage of resources required by the directory server. i.e. you may have a full disk etc
ldap_mod_replace() [function.ldap-mod-replace]: Modify: Server is unwilling to perform has some requirements as well
One possibility is what I did... I misconfigured /etc/ldap.conf, and added binddn where I meant to put rootbinddn, and that caused this message.
I had this error. Ldap on virtual machine on windows server 2019 on 10.0.0.14 IP.
I managed to connect and bind successfuly, but this error occurs when ldap_add().
My solution was to check $record array parameters that i want to save.
I this set of properties work for me:
$r = ldap_add($this->LdapConn, 'CN=user 3,'.$this->Branch, array(
'cn' => 'user 3',
'name' => 'test',
'sn' => 'asd',
'instanceType' => '4',
'objectCategory'=> 'CN=Person,CN=Schema,CN=Configuration,DC=test-domain,DC=com',
'mail' => 'mai222222l#mail2.com',
'objectclass'=>array(
'top',
'user',
'person',
'organizationalPerson'
)
));
Note that ldap_add() second parameter is path (dn) to entry and this can cause problem.
Path(dn) must be current branch + entry
For me current branch was 'CN=Users,DC=test-domain,DC=com' and full path mean dn = "CN=user 3,CN=Users,DC=test-domain,DC=com"
Note that this first part cn=user 3 must be the same as in bellow array.
My distinguish names (dc) was incorrect.
I am new to both postgres and postfix, I decided to use to postfixadmin with Postgres to gain so hands on, I have ran through detailed steps mentioned in different websites, and I have checked another working installation of Postgres (but without postfixadmin), but whenever I accessing the setup.php for postfixadmin from http://mydomain.com:8080 I am getting:
Error: Can't connect to database
Please edit the $CONF['database_*'] parameters in config.inc.php.
DEBUG INFORMATION:
Connect: failed to connect to database.
I configured the postfixadmin to use initially postfix user, but as the postfix is created by default as no login user, so I created another user called admin and changed this in config.inc.php as well, but I am still getting the same error
Here are the user created on the system related to this stuff:
# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
admin:x:500:500::/home/admin:/bin/bash
Here am I configuring the user admin in Postgres:
# su - postgres
-bash-4.1$ template1
-bash: template1: command not found
-bash-4.1$ template1#
-bash: template1#: command not found
-bash-4.1$ psql template1
psql (8.4.18)
Type "help" for help.
template1=# CREATE USER admin WITH PASSWORD 'complexpassword';
CREATE ROLE
template1=# GRANT ALL PRIVILEGES ON DATABASE postfix to admin;
GRANT
template1=# \q
-bash-4.1$ logout
Here are the configuration of the Postgres:
-bash-4.1$ psql
psql (8.4.18)
Type "help" for help.
postgres=# \list
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postfix | postfix | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postfix
: postfix=CTc/postfix
: admin=CTc/postfix
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
(4 rows)
Here is postgresql.conf:
#cat postgresql.conf
listen_addresses = 'localhost' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
shared_buffers = 32MB # min 128kB
synchronous_commit = off # optimization
log_destination = 'stderr' # Valid values are combinations of
logging_collector = on # Enable capturing of stderr and csvlog
log_directory = 'pg_log' # directory where log files are written,
log_filename = 'postgresql-%a.log' # log file name pattern,
log_truncate_on_rotation = on # If on, an existing log file of the
log_rotation_age = 1d # Automatic rotation of logfiles will
log_rotation_size = 0 # Automatic rotation of logfiles will
datestyle = 'iso, mdy'
lc_messages = 'en_US.UTF-8' # locale for system error message
lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
lc_numeric = 'en_US.UTF-8' # locale for number formatting
lc_time = 'en_US.UTF-8' # locale for time formatting
default_text_search_config = 'pg_catalog.english'
Here I am testing user admin:
# su - admin
$ psql -d postfix -U admin
psql (8.4.18)
Type "help" for help.
postfix=> exit
postfix-> \q
Here I am testing postfix user (nologin):
# su - postfix
This account is currently not available.
Here is the config.inc.php for postfixadmin:
<?php
$CONF['configured'] = true;
$CONF['setup_password'] = 'complexpassword';
$CONF['postfix_admin_path'] = dirname(__FILE__);
$CONF['default_language'] = 'en';
$CONF['database_type'] = 'pgsql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'admin';
$CONF['database_password'] = 'complexpassword';
$CONF['database_name'] = 'postfix';
$CONF['database_port'] = '5432';
$CONF['database_prefix'] = '';
$CONF['database_tables'] = array (
'admin' => 'admin',
'alias' => 'alias',
'alias_domain' => 'alias_domain',
'config' => 'config',
'domain' => 'domain',
'domain_admins' => 'domain_admins',
'fetchmail' => 'fetchmail',
'log' => 'log',
'mailbox' => 'mailbox',
'vacation' => 'vacation',
'vacation_notification' => 'vacation_notification',
'quota' => 'quota',
'quota2' => 'quota2',
);
$CONF['admin_email'] = 'postmaster#mydomain.com';
$CONF['smtp_server'] = 'localhost';
$CONF['smtp_port'] = '25';
$CONF['encrypt'] = 'md5crypt';
$CONF['authlib_default_flavor'] = 'md5raw';
$CONF['min_password_length'] = 5;
$CONF['generate_password'] = 'NO';
$CONF['show_password'] = 'NO';
$CONF['page_size'] = '10';
$CONF['default_aliases'] = array (
'abuse' => 'abuse#mydomain.com',
'hostmaster' => 'hostmaster#mydomain.com',
'postmaster' => 'postmaster#mydomain.com',
'webmaster' => 'webmaster#mydomain.com'
);
$CONF['domain_path'] = 'NO';
$CONF['domain_in_mailbox'] = 'YES';
$CONF['maildir_name_hook'] = 'NO';
maildir_name_hook example function
Called by create-mailbox.php if $CONF['maildir_name_hook'] == '<name_of_the_function>'
- allows for customized maildir paths determined by a custom function
- the example below will prepend a single-character directory to the
beginning of the maildir, splitting domains more or less evenly over
36 directories for improved filesystem performance with large numbers
of domains.
Returns: maildir path
function maildir_name_hook($domain, $user) {
$chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$dir_index = hexdec(substr(md5($domain), 28)) % strlen($chars);
$dir = substr($chars, $dir_index, 1);
}
$CONF['aliases'] = '10';
$CONF['mailboxes'] = '10';
$CONF['maxquota'] = '10';
$CONF['quota'] = 'NO';
$CONF['quota_multiplier'] = '1024000';
$CONF['transport'] = 'NO';
$CONF['transport_options'] = array (
);
$CONF['transport_default'] = 'virtual';
$CONF['vacation'] = 'NO';
$CONF['vacation_domain'] = 'autoreply.hassans.nl';
$CONF['vacation_control'] ='YES';
$CONF['vacation_control_admin'] = 'YES';
$CONF['alias_control'] = 'NO';
$CONF['alias_control_admin'] = 'NO';
$CONF['special_alias_control'] = 'NO';
$CONF['alias_goto_limit'] = '0';
$CONF['alias_domain'] = 'YES';
$CONF['backup'] = 'YES';
$CONF['sendmail'] = 'YES';
$CONF['logging'] = 'YES';
$CONF['fetchmail'] = 'YES';
$CONF['fetchmail_extra_options'] = 'NO';
$CONF['show_header_text'] = 'NO';
$CONF['header_text'] = ':: Postfix Admin ::';
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'Return to mail.mydomain.com';
$CONF['welcome_text'] = <<<EOM
Hi,
Welcome to your new account.
EOM;
$CONF['emailcheck_resolve_domain']='YES';
$CONF['show_status']='NO';
$CONF['show_status_key']='NO';
$CONF['show_status_text']=' ';
$CONF['show_undeliverable']='NO';
$CONF['show_undeliverable_color']='tomato';
$CONF['show_undeliverable_exceptions']=array("unixmail.domain.ext","exchangeserver.domain.ext","gmail.com");
$CONF['show_popimap']='NO';
$CONF['show_popimap_color']='darkgrey';
$CONF['show_custom_domains']=array("subdomain.domain.ext","domain2.ext");
$CONF['show_custom_colors']=array("lightgreen","lightblue");
$CONF['recipient_delimiter'] = "";
$CONF['create_mailbox_subdirs_prefix']='INBOX.';
$CONF['used_quotas'] = 'NO';
$CONF['new_quota_table'] = 'NO';
$CONF['xmlrpc_enabled'] = false;
}
Here are the php packages installed:
#rpm -qa| grep php
php-common-5.3.3-26.el6.x86_64
php-pgsql-5.3.3-26.el6.x86_64
php-xmlrpc-5.3.3-26.el6.x86_64
php-cli-5.3.3-26.el6.x86_64
php-5.3.3-26.el6.x86_64
php-gd-5.3.3-26.el6.x86_64
php-pear-1.9.4-4.el6.noarch
php-imap-5.3.3-26.el6.x86_64
php-xml-5.3.3-26.el6.x86_64
php-pdo-5.3.3-26.el6.x86_64
php-mbstring-5.3.3-26.el6.x86_64
Here are the checks showing that the Postgres is listening to posrt 5432:
#netstat -an|grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 12136 /tmp/.s.PGSQL.5432
# telnet localhost 5432
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
But What is really strange as well when I try to run the setup.php page I can see the following:
# netstat -an| grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:45445 127.0.0.1:5432 TIME_WAIT
unix 2 [ ACC ] STREAM LISTENING 12136 /tmp/.s.PGSQL.5432
The Postgres' log contains:
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
FATAL: Ident authentication failed for user "postfix"
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
FATAL: Ident authentication failed for user "postfix"
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
FATAL: Ident authentication failed for user "postfix"
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused FATAL:
Ident authentication failed for user "admin"
And the pg_hba.conf is:
local all all ident
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
Can someone guide me what is wrong?
Find in the pg_hba.conf(this file is in the same directory as the postgresql.conf) a line starting with "host", containing "127.0.0.1/32" in it and ending with "ident" and change the "ident" to "md5". Reload/restart Postgres.
I tried to rename my database (I am using hostmonster) and now nothing is loading on my page. I can't seem to find any documentation anywhere on this. I renamed the database back to what it originally was and I still getting the same error and nothing is loading on my page now. I am using codeigniter (as the title would suggest). The following error is:
A Database Error Occurred
Unable to select the specified database: xxxxx
Filename: core/Loader.php
Line Number: 346
I go to this file and there is nothing of relevance there:
// Load the DB class
$CI->db =& DB($params, $active_record);
Do I have to completely re-install my files to the server now? Here is what database.php looks like...
$active_group = 'main';
$active_record = TRUE;
$db['main']['hostname'] = 'localhost';
$db['main']['username'] = 'xxxx';
$db['main']['password'] = 'xxxx';
$db['main']['database'] = 'xxxx';
$db['main']['dbdriver'] = 'mysql';
$db['main']['dbprefix'] = '';
$db['main']['pconnect'] = TRUE;
$db['main']['db_debug'] = TRUE;
$db['main']['cache_on'] = FALSE;
$db['main']['cachedir'] = '';
$db['main']['char_set'] = 'utf8';
$db['main']['dbcollat'] = 'utf8_general_ci';
$db['main']['swap_pre'] = '';
$db['main']['autoinit'] = TRUE;
$db['main']['stricton'] = FALSE;
Obviously, I don't really use the (xxxx)'s...
In your control panel , go to MySQL Databases
I assumed you have already created a user , Now what you are missing out ... is that you did not add the user to the database
after adding , confirm the necessary permission , then you are good to go!
Set $db['default']['pconnect'] = FALSE;. Here mysql_pconnect() is disabled, So we are using mysql_connect().
open application->config->database.php
and set the configuration variable
$db['default']['database'] = 'new name';
Using command prompt/terminal, type in the following from your mysql bin folder:
mysql -u USER -h localhost -p PASSWORD DATABASENAME
See if that throws any issues at you (wrong password, wrong database name, etc..). Make sure you use the same text from your configs (copy/paste).
I had same problem under CPanel.
It helped to set:
$db['main']['db_debug'] = FALSE;