0

I am trying to connect database using codeigniter 3 but i am facing this issue anybody please help.

A PHP Error was encountered Severity: Warning Message: mysqli::real_connect(): (HY000/2005): Unknown MySQL server host 'pd8344-001.privatesql' (2) Filename: mysqli/mysqli_driver.php Line Number: 202 Backtrace: File: /var/www/html/importdb/index.php Line: 292 Function: require_once

And

A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: core/CodeIgniter.php Line Number: 500

here is my db setting in config file.

$db['default'] = array(
'dsn'   => '',
'hostname' => 'pd8344-001.privatesql',
'port'     => '3306',
'username' => '****',
'password' => '****',
'database' => 'db_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,//(ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
8
  • 1
    Your hostname should be IP address or domain name or localhost. Commented Feb 7, 2016 at 17:01
  • hi, thanks for your reply. one thing my client only get phpmyadmin from hosting provider so there is a need for ip , domain or server name will work like for hostname? Commented Feb 7, 2016 at 17:18
  • 1
    When you login in phpadmin, somewhere on the top or eventually on the right of root/main page should be server name. Very often DB server is on the same server where files are, so could be working with localhost. Commented Feb 7, 2016 at 17:20
  • 1
    Is there some IP too? Commented Feb 7, 2016 at 17:25
  • 1
    Best way is to ask support for provided service (MySQL DB) because without that information you won't be able to connect to DB. Commented Feb 7, 2016 at 17:30

1 Answer 1

0

Set the hostname in your database config file to the actual hostname of the database server and it should then work as expected.

A valid hostname is either a domain, or IP. Rather than pd8344-001.privatesql I would expect to see something more like pd8344-001.privatesql.com for example.

If you are having trouble finding the hostname and your host provides a phpMyAdmin interface, log into your phpMyAdmin account and copy the current URL with everything after (and including) "/phpMyAdmin" removed.

E.g.

pd8344-001.privatesql.com/phpMyAdmin?sess=213123123123&stuff=21314123123&more=sadhfasdjhgfasd

You should get

pd8344-001.privatesql.com
Sign up to request clarification or add additional context in comments.

4 Comments

yes , i did it but now i am facing this issue "Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 347"
Contact your host and ask what your database hostname is
can you please make sure it is host problem so that i can discuss with him?
Its not a problem with the host. The problem is that you do not have the correct hostname for the database server. It's like trying to get to a website without the domain name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.