LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 07-18-2013, 10:42 AM   #16
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184

Quote:
Originally Posted by Horus1 View Post
Unknown MySQL server host '#localhost' (1)
Full example please. How did you call it, from where etc.

Also just leave the # out of the hostname. Makes things easier.
 
Old 07-18-2013, 09:13 PM   #17
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by zhjim View Post
Full example please. How did you call it, from where etc.

Also just leave the # out of the hostname. Makes things easier.
I call it from horusone.com/dbtest.php
After edit
Code:
/etc/resolv.conf
Code:
#nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
 
Old 07-18-2013, 10:22 PM   #18
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
is this can help to know where the error
Code:
# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0     52 server4.horusone.co:ssh 197.123.230.159:4670    ESTABLISHED
udp        0      0 server4.horusone.:53693 google-public-dn:domain ESTABLISHED
udp        0      0 server4.horusone.:33375 google-public-dn:domain ESTABLISHED
udp        0      0 server4.horusone.:11112 197.199.255.254:domain  ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  19     [ ]         DGRAM                    2565430886 /dev/log
unix  2      [ ]         DGRAM                    3579677224
unix  2      [ ]         DGRAM                    3579276991
unix  2      [ ]         DGRAM                    680077175
unix  3      [ ]         STREAM     CONNECTED     2614398106
unix  3      [ ]         STREAM     CONNECTED     2614398105
unix  2      [ ]         DGRAM                    2613834810
unix  3      [ ]         STREAM     CONNECTED     2613834770
unix  3      [ ]         STREAM     CONNECTED     2613834769
unix  3      [ ]         STREAM     CONNECTED     2613834753
unix  3      [ ]         STREAM     CONNECTED     2613834752
unix  3      [ ]         STREAM     CONNECTED     2613834742
unix  3      [ ]         STREAM     CONNECTED     2613834741
unix  3      [ ]         STREAM     CONNECTED     2613834738
unix  3      [ ]         STREAM     CONNECTED     2613834737
unix  3      [ ]         STREAM     CONNECTED     2613834734
unix  3      [ ]         STREAM     CONNECTED     2613834733
unix  3      [ ]         STREAM     CONNECTED     2613834730
unix  3      [ ]         STREAM     CONNECTED     2613834729
unix  3      [ ]         STREAM     CONNECTED     2613834726
unix  3      [ ]         STREAM     CONNECTED     2613834725
unix  3      [ ]         STREAM     CONNECTED     2613834722
unix  3      [ ]         STREAM     CONNECTED     2613834721
unix  3      [ ]         STREAM     CONNECTED     2613834718
unix  3      [ ]         STREAM     CONNECTED     2613834717
unix  3      [ ]         STREAM     CONNECTED     2613834714
unix  3      [ ]         STREAM     CONNECTED     2613834713
unix  3      [ ]         STREAM     CONNECTED     2613834710
unix  3      [ ]         STREAM     CONNECTED     2613834709
unix  3      [ ]         STREAM     CONNECTED     2613834706
unix  3      [ ]         STREAM     CONNECTED     2613834705
unix  3      [ ]         STREAM     CONNECTED     2613834702
unix  3      [ ]         STREAM     CONNECTED     2613834701
unix  3      [ ]         STREAM     CONNECTED     2613834698
unix  3      [ ]         STREAM     CONNECTED     2613834697
unix  3      [ ]         STREAM     CONNECTED     2613834694
unix  3      [ ]         STREAM     CONNECTED     2613834693
unix  3      [ ]         STREAM     CONNECTED     2613834690
unix  3      [ ]         STREAM     CONNECTED     2613834689
unix  3      [ ]         STREAM     CONNECTED     2613834686
unix  3      [ ]         STREAM     CONNECTED     2613834685
unix  3      [ ]         STREAM     CONNECTED     2613834682
unix  3      [ ]         STREAM     CONNECTED     2613834681
unix  3      [ ]         STREAM     CONNECTED     2613834678
unix  3      [ ]         STREAM     CONNECTED     2613834677
unix  3      [ ]         STREAM     CONNECTED     2613834674
unix  3      [ ]         STREAM     CONNECTED     2613834673
unix  3      [ ]         STREAM     CONNECTED     2613834670
unix  3      [ ]         STREAM     CONNECTED     2613834669
unix  3      [ ]         STREAM     CONNECTED     2613834666
unix  3      [ ]         STREAM     CONNECTED     2613834665
unix  3      [ ]         STREAM     CONNECTED     2613834662
unix  3      [ ]         STREAM     CONNECTED     2613834661
unix  3      [ ]         STREAM     CONNECTED     2613834658
unix  3      [ ]         STREAM     CONNECTED     2613834657
unix  3      [ ]         STREAM     CONNECTED     2613834654
unix  3      [ ]         STREAM     CONNECTED     2613834653
unix  3      [ ]         STREAM     CONNECTED     2613834650
unix  3      [ ]         STREAM     CONNECTED     2613834649
unix  3      [ ]         STREAM     CONNECTED     2613834646
unix  3      [ ]         STREAM     CONNECTED     2613834645
unix  3      [ ]         STREAM     CONNECTED     2613834642
unix  3      [ ]         STREAM     CONNECTED     2613834641
unix  3      [ ]         STREAM     CONNECTED     2613834636
unix  3      [ ]         STREAM     CONNECTED     2613834635
unix  3      [ ]         STREAM     CONNECTED     2613834631
unix  3      [ ]         STREAM     CONNECTED     2613834630
unix  3      [ ]         STREAM     CONNECTED     2613834625
unix  3      [ ]         STREAM     CONNECTED     2613834624
unix  3      [ ]         STREAM     CONNECTED     2613834621
unix  3      [ ]         STREAM     CONNECTED     2613834620
unix  3      [ ]         STREAM     CONNECTED     2613834618
unix  3      [ ]         STREAM     CONNECTED     2613834617
unix  3      [ ]         STREAM     CONNECTED     2613834609
unix  3      [ ]         STREAM     CONNECTED     2613834608
unix  3      [ ]         STREAM     CONNECTED     2613834599
unix  3      [ ]         STREAM     CONNECTED     2613834598
unix  2      [ ]         DGRAM                    2613834565
unix  2      [ ]         DGRAM                    2613833381
unix  2      [ ]         DGRAM                    2613832205
unix  2      [ ]         DGRAM                    2613821827
unix  2      [ ]         DGRAM                    2613820763
unix  2      [ ]         DGRAM                    2613812172
unix  2      [ ]         DGRAM                    2613812130
unix  2      [ ]         DGRAM                    2613812080
unix  2      [ ]         DGRAM                    2613812018
unix  2      [ ]         DGRAM                    2613811961
unix  2      [ ]         STREAM     CONNECTED     2613811800
unix  2      [ ]         DGRAM                    2565432300
unix  2      [ ]         DGRAM                    2565432114
unix  2      [ ]         DGRAM                    2565431962
 
Old 07-19-2013, 02:35 AM   #19
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
Quote:
Originally Posted by Horus1 View Post
I call it from horusone.com/dbtest.php
Okay show me the example code you have.

Quote:
Originally Posted by Horus1 View Post
After edit
Code:
/etc/resolv.conf
Code:
#nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
Okay that should be better. So now your local resolves through the content of /etc/hosts.
 
Old 07-19-2013, 02:37 AM   #20
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
Quote:
Originally Posted by Horus1 View Post
is this can help to know where the error
Not really please use the command I gave on the first page.

Just another thing please get into the habit of beeing as specific as possible and also follow the advices given exactly. Else you post things that are of less value that is possible and I can't help you to the fullest extend.
 
Old 07-19-2013, 07:25 AM   #21
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by zhjim View Post
Okay show me the example code you have.
this is code of dbtest
Code:
<?php

//connect to MySQL Server

$conn = mysql_connect("#localhost", "#u_name ", "#password");
if (!$conn)
  {
    die(mysql_error());
  }
else
  {
    echo "1. Successfully connected to MySQL database server.<br /><br />";
  }

// select database

$db_sel = mysql_select_db('#db_name', $conn);
if (!$db_sel)
  {
    die ('cant\'t use database: ' . mysql_error());
  }
else
  {
    echo "2. WordPress database selected. <br />";
  }

?>
 
Old 07-19-2013, 08:13 AM   #22
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
Code:
$conn = mysql_connect("#localhost", "#u_name ", "#password");
like I said in a previous post leave out the # in front of the localhost.
Beside that the connect will not succeded the way you are calling it. What you are doing translates to the use of the command line mysql programm:
Code:
mysql -h #localhost -u #u_name -p#password
Honestly I think you don't know what you are doing. Where did you get that code from? If from a tutorial you did not read it but just copy it.
You have to replace #localhost with the name of your host. In this case localhost. #u_name should be replaced with the name of the user you want to connect with. Use root. the same goes for the #password.
So it should be like

Code:
$conn = mysql_connect("localhost", "root", "your_password_for_the_root_account");
After this it should connect. But you'll run into trouble when selecting the database. Read up on variables in php and the difference between using ' (single quote) and " (double quote).

Last edited by zhjim; 07-19-2013 at 10:52 AM.
 
Old 07-19-2013, 09:31 AM   #23
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
after i did follow your last post

call it from horusone.com/dbtest.php

Quote:
1. Successfully connected to MySQL database server.

2. WordPress database selected.
call it from horusone.com
Quote:
Error establishing a database connection
 
Old 07-19-2013, 09:34 AM   #24
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
after i did follow your last post

call it from horusone.com/dbtest.php

Quote:
1. Successfully connected to MySQL database server.

2. WordPress database selected.
from horusone.com
Quote:
Error establishing a database connection
 
Old 07-19-2013, 10:36 AM   #25
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6
Posts: 1,549

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Now check your wp-config.php settings to ensure that you have them correctly specified. You're looking for this nead the top of the file:

Code:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'your_wordpress_database_name');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'your_password_for_the_root_account');

/** MySQL hostname */
define('DB_HOST', 'localhost');
 
Old 07-19-2013, 10:50 AM   #26
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
Now check your wp-config.php settings to ensure that you have them correctly specified. You're looking for this nead the top of the file:

Code:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'your_wordpress_database_name');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'your_password_for_the_root_account');

/** MySQL hostname */
define('DB_HOST', 'localhost');
I'm sure wp-config.php settings is correct,

all info the same since my first post , and now we know the correct hostname (localhost)
please where the error ?
 
Old 07-19-2013, 10:54 AM   #27
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
Is the program still containing the following?
Code:
// select database

$db_sel = mysql_select_db('#db_name', $conn);
If not please post the edited version.
 
Old 07-19-2013, 06:08 PM   #28
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by zhjim View Post
Is the program still containing the following?
Code:
// select database

$db_sel = mysql_select_db('#db_name', $conn);
If not please post the edited version.
the content is
Code:
// select database

$db_sel = mysql_select_db("u2642_yp", $conn);
 
Old 07-21-2013, 11:21 AM   #29
Horus1
LQ Newbie
 
Registered: Jul 2013
Posts: 28

Original Poster
Rep: Reputation: Disabled
solved, change wp-conf file by fresh one
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql error connect to server at 'localhost' failed pete44904 Linux - Server 10 11-23-2012 07:08 AM
mysqladmin: connect to server at 'localhost' failed(Confusion abot MySQL and mysqladm Terry56 Linux - Server 4 03-10-2010 08:20 AM
Can't connect to (non localhost) mysql server from laptop or desktop. DiBosco Linux - Server 9 01-20-2008 01:32 PM
mysqladmin: connect to server at 'localhost' failed... bluetxxth Fedora 4 10-07-2007 11:42 AM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration