473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

QLSTATE[HY000] [2002] Can't connect to local MySQL server through socket

It's my first time learn hosting for my final assignment
i got this error

Expand|Select|Wrap|Line Numbers
  1. Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' in /home/vol13/000space.com/space_4876282/htdocs/CakeShopOnline/library/Zend/Db/Adapter/Pdo/Abstract.php:143 Stack trace: #0 /home/vol13/000space.com/space_4876282/htdocs/CakeShopOnline/library/Zend/Db/Adapter/Abstract.php(414): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 /home/vol13/000space.com/space_4876282/htdocs/CakeShopOnline/library/Zend/Db/Adapter/Pdo/Abstract.php(220): Zend_Db_Adapter_Abstract->query('select sum(JumD...', Array) #2 /home/vol13/000space.com/space_4876282/htdocs/CakeShopOnline/library/Zend/Db/Adapter/Abstract.php(660): Zend_Db_Adapter_Pdo_Abstract->query('select sum(JumD...', Array) #3 /home/vol13/000space.com/space_4876282/htdocs/CakeShopOnline/application/models/DataCart.php(30): Zend_Db_Adapter_Abstract->fetchRow('select sum(JumD...') #4 /home/vol13/000space.com/space_4876282/htdocs/CakeShopOnline/application/contro in /home/vol13/000space.com/space_4876282/htdocs/CakeShopOnline/library/Zend/Db/Adapter/Pdo/Abstract.php on line 143
I have no idea what should i do
I get no error when i'm on local..
Jan 12 '10 #1
18 10856
dgreenhouse
250 Expert 100+
It might be that you don't have the database connection credentials set correctly for the hosting site.

You probably have settings like: localhost on your home system and the external host might need to point to an external MySQL machine. If MySQL is on an external box, you can't specify using UNIX sockets - you have to use TCP/IP.

As you might imagine, you'll have to do some digging and this is the nature of the beast that you've elected to get involved with.
[Computers can be a REAL PAIN! ;-)]

It also might be that mysqld.sock is in a different location on the hosting server or it's named something else.

If you have SSH access (and you know how to use it) try this command:
find / -iname "mysql*.sock".

Or you can try this to see how MySQL is actually connected.
netstat -ln | grep mysql

I'm running a CentOS box locally and it's located in: /var/lib/mysql/mysql.sock. Many times it's in the /tmp/ directory.

You can also ask the hosting company's tech support - they may have an answer because this is a common problem.

There are a number links you can find by Googling that address this issue.
One of possible interest is: http://lenss.nl/2009/06/zend_db-conn...-mysql-socket/

Finally, Zend's adapter has had known issues in the past, but I assume you're setup is up to date.
Jan 13 '10 #2
uhm,
i'll try now >.<
thank you so much ^^


but my web use database to show catalog too
and the catalog can shows normally just like in local
i'm really confuse x__x
Jan 13 '10 #3
dgreenhouse
250 Expert 100+
@AngelinaB
I'm unclear on what you're asking in the above...
Jan 14 '10 #4
Niheel
2,460 Expert Mod 2GB
Angelina please write in complete sentences with proper punctuation so that other members can understand what you are trying to say.
Jan 14 '10 #5
sorry for my bad english
I was sick so could not think clearly.

I'm trying to say that my website using sql query to display the items in the catalog and I did not get an error like the login process ( error above)

once again sorry for my bad english.
Jan 14 '10 #6
dgreenhouse
250 Expert 100+
AngelinaB,

I don't know the particulars of your application; especially that which is related to the 'catalog', so it's impossible to advice you without more information.

Can you explain a little about your course, what your trying to accomplish at this juncture in the class, what the requirements are, etc.?

Best,
Jan 14 '10 #7
hi2..

oc. i'll try to explain but i'm really sorry for my bad english..

my final assignment is make an ecommerce website (study case)
on my main page there are sections to login and recommended items.
on recommended items I did the calculation of the database by looking for the best-selling items (and I do not get an error) but if I try to login I get an error as above.
that's make me so confuse..

btw thank you very much for your replies..
I'm sorry I forgot to say thank you earlier
Jan 14 '10 #8
dgreenhouse
250 Expert 100+
You obviously can connect to the database for doing the calculation, so... it might be that you're using a different connection modality to connect to the database when attempting the login...

Why don't you post some of the code; sans username and password?

Aren't you using he Zend abstraction layer?

As a matter of fact, post the code you use when connecting to do the calculation along with the code for logging in...

Try an online beautifier for the code and of course embed that in a [ code ] ... [ /code ] pair.

Beautifier - one of many:
http://beta.phpformatter.com/
Jan 14 '10 #9
hi..

yes sir, i'll do..
this is my code for calculation
Expand|Select|Wrap|Line Numbers
  1. //controller
  2. $sj= new DataTrans();
  3. $jml = $sj->getjmlmostbuy();
  4. $this->view->dmostbuy=$sj->getmostbuy2($jml);
  5.  
  6. //model
  7. function getjmlmostbuy() {
  8.     $DB = new Zend_Db_Adapter_Pdo_Mysql($this->__construct());
  9.     $sql="select max(A.cnt) as jml  ";
  10.     $sql=$sql."from( Select sum(dt.JumDItemDTrans) as cnt  ";
  11.     $sql=$sql."from DTrans dt, DItem di  ";
  12.     $sql=$sql."where  dt.IdDItemDTrans = di.IdDItem ";
  13.     $sql=$sql."group by (di.IdDItem)) as A ";
  14.     $data=$DB->fetchRow($sql);
  15.     return $data['jml'];
  16. }
  17. function getmostbuy($jml)
  18. {
  19.     $DB = new Zend_Db_Adapter_Pdo_Mysql($this->__construct());
  20.     $sql="select di.IdDItem as iditem, di.NamaDITem as namaitem, di.UkuranDItem as ukuranitem, ";
  21.     $sql=$sql."di.HargaDItem as hargaitem, sum(dt.JumDItemDTrans)as jumlahitem ";
  22.     $sql=$sql."from DTrans dt, DItem di ";
  23.     $sql=$sql."where di.IdDItem = dt.IdDItemDTrans ";
  24.     $sql=$sql."and sum(dt.JumDItemDTrans) = '".$jml."'";
  25.     $sql=$sql."group by di.IdDItem ";
  26.     return $DB->fetchAll($sql);
  27. }
  28.  
and this is my code to loggin
Expand|Select|Wrap|Line Numbers
  1. //controller
  2. if ($this->_request->isPost())
  3. {
  4.     Zend_Loader::loadClass('Zend_Filter_StripTags');
  5.     $f = new Zend_Filter_StripTags();
  6.     $user = $f->filter($this->_request->getPost('user'));
  7.     $pass = $f->filter($this->_request->getPost('pass'));
  8.     if (empty($user))
  9.     {
  10.         $this->view->message = 'Insert UserName.';
  11.     } else
  12.     {
  13.         //check admin dlu
  14.         Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
  15.         $db = Zend_Registry::get('db');
  16.         $authAdapter = new Zend_Auth_Adapter_DbTable($db);
  17.         $authAdapter->setTableName('Admin');
  18.         $authAdapter->setIdentityColumn('NamaAdmin');
  19.         $authAdapter->setCredentialColumn('PassAdmin');
  20.         // Set the input credential values to authenticate against
  21.         $authAdapter->setIdentity($user);
  22.         $authAdapter->setCredential($pass);
  23.         // do the authentication
  24.         $auth = Zend_Auth::getInstance();
  25.         $result = $auth->authenticate($authAdapter);
  26.         if ($result->isValid())
  27.         {
  28.             // success: admin
  29.             $data = $authAdapter->getResultRowObject(null,'password');
  30.             $auth->getStorage()->write($data);
  31.             $identity = $auth->getIdentity();
  32.             $_SESSION['nmuser']=$user;
  33.             $_SESSION['username']=$user;
  34.             $_SESSION['userid']=$id;
  35.             $_SESSION['userlvl']=1;
  36.             $this->view->link='logout';
  37.             $this->view->links='Log Out';
  38.             $this->view->index='1';
  39.             $this->_redirect('/admin/admin');
  40.         } else
  41.         {
  42.             //check user
  43.             Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
  44.             $db = Zend_Registry::get('db');
  45.             $authAdapter = new Zend_Auth_Adapter_DbTable($db);
  46.             $authAdapter->setTableName('User');
  47.             $authAdapter->setIdentityColumn('EmailUser');
  48.             $authAdapter->setCredentialColumn('PassUser');
  49.             // Set the input credential values to authenticate against
  50.             $authAdapter->setIdentity($user);
  51.             $authAdapter->setCredential($pass);
  52.             // do the authentication
  53.             $auth = Zend_Auth::getInstance();
  54.             $result = $auth->authenticate($authAdapter);
  55.             if ($result->isValid())
  56.             {
  57.                 $data = $authAdapter->getResultRowObject(null,'password');
  58.                 $auth->getStorage()->write($data);
  59.                 $identity = $auth->getIdentity();
  60.                 $id= $identity->IdUser;
  61.                 $DataUser = new DataUser ();
  62.                 $nmuser = $DataUser->searchnmuser($id);
  63.                 $_SESSION['username']=$user;
  64.                 $_SESSION['userid']=$id;
  65.                 $_SESSION['nmuser']=$nmuser;
  66.                 $_SESSION['userlvl']=2;
  67.                 $_SESSION['status']='login';
  68.                 if(isset($_POST['remember'])){
  69.                     setcookie("username", $_SESSION['username'], time()+60*60*24*60, "/");
  70.                     setcookie("userid", $_SESSION['userid'], time()+60*60*24*60, "/");
  71.                     setcookie("nmuser", $_SESSION['nmuser'], time()+60*60*24*60, "/");
  72.                     setcookie("userlvl", $_SESSION['userlvl'], time()+60*60*24*60, "/");
  73.                 }
  74.  
  75.                 //tampilkan bnyak item dari dtcart sesuai user d menu
  76.                 if ($_SESSION['userid'] != '') {
  77.                     $DataCart = new DataCart();
  78.                     $this->view->jumcart = $DataCart->getjumitemcart($_SESSION['userid']);
  79.                 }
  80.                 $this->view->link='logout';
  81.                 $this->view->links='Log Out';
  82.                 $this->view->index='1';
  83.             } else
  84.             {
  85.                 // failure: clear database row from session
  86.                 $this->view->message = 'Login Failed';
  87.                 $this->view->index='0';
  88.             }
  89.         }
  90.     }
  91. }
  92.  
thank you for helping and sorry to bother you ..

how embarrassing me U__U
yes sir, have a lot of good rest

once again thank you for helping ..
Jan 14 '10 #10
dgreenhouse
250 Expert 100+
A...

By the way... The [ code ] ... [ / code ] are without spaces...

I just showed it that way because it wouldn't show on the screen otherwise...

At least you're listening! :-)

I'm probably about to fade and will be back up in a few hours... I've been up for about 20 hours.

----

At which line in the code are you getting error?
Jan 14 '10 #11
i've edited it >.<

have a good rest sir..
Jan 14 '10 #12
dgreenhouse
250 Expert 100+
Did you get it to work?

I'll be up for another 30 minutes...

By the way... It's cool you're learning MVC and Patterns...

If you like this work, you'll definitely find a good place in the field.

I know a bunch of great female geeks (Gerds) that are doing great stuff in the field.

Check this out: http://girldeveloper.com/ - Sara's really cool and funny ta boot!
Jan 14 '10 #13
hmm my reply doesnt entered x__x'

no sir.. it's still error and the error on the above always bold in this code
Expand|Select|Wrap|Line Numbers
  1. /home/vol13/000space.com/space_4876282/htdocs/CakeSh
  2. opOnline/library/Zend/Db/Adapter/Pdo/Abstract.php 
  3. on line 143
  4.  
I really don't know where is the wrong section and tomorrow is my final assignment trial, it's seems I had to demostrate through virtual host >__<

but I will keep trying to find out where my mistake because I was really curious so please help me again sir, it's alright?

yes sir, i do like php programming and it seems I still have to learn a lot..
so please guidance me :D

woghhhh that was a cool web.
if sara real sir? sara looks great >__<
Jan 14 '10 #14
dgreenhouse
250 Expert 100+
@AngelinaB
Yep... Sara's the real McCoy
Jan 14 '10 #15
dgreenhouse
250 Expert 100+
Just start inserting print statements starting at this line:
Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable' );

something like this:
Expand|Select|Wrap|Line Numbers
  1. Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
  2.  
  3. /* Debugging */
  4. print "Got Here!";
  5. exit;
  6. /* Debugging */
  7.  
  8. $db = Zend_Registry::get('db');
  9. $authAdapter = new Zend_Auth_Adapter_DbTable($db);
  10. $authAdapter->setTableName('Admin');
  11. $authAdapter->setIdentityColumn('NamaAdmin');
  12. $authAdapter->setCredentialColumn('PassAdmin');
  13. // Set the input credential values to authenticate against
  14. $authAdapter->setIdentity($user);
  15. $authAdapter->setCredential($pass);
  16. // do the authentication
  17. $auth = Zend_Auth::getInstance();
  18. ...
  19.  
And continue to move the print (debugging) statement down until you get the failure.

I assume you'll get it on the first line.

On a another note...
Where is the class DataTrans defined?
$sj= new DataTrans();

Somewhere in its execution path a connection is obviously getting instanced properly, but I do understand the need to create the authentication construct in the login part.

Maybe therein you'll find some differences in connection configurations, but I'd think they should be compartmentalized in one place - as I know is the normal case. But I've written some pretty squirrelly code myself that I've had to wonder what idiot wrote it! :-)
Jan 14 '10 #16
uhm..
my post doesn't entered again x__x'

hi..

I've written classes that are needed in index.php
and DataTrans defined in models area

this is my code in DataTrans
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
  3. require_once 'mysql.php';
  4. class DataTrans
  5. {
  6.     public function __construct()
  7.     {
  8.         $params = array(
  9.             'host' => dbHost,
  10.             'username' => dbUser,
  11.             'password' => dbPass,
  12.             'dbname' => dbName
  13.         );
  14.         return $params;
  15.     }
  16.     //another function..
  17. }
  18.  
i've defiend all of parameters in construct too like this
Expand|Select|Wrap|Line Numbers
  1. define('dbHost','sql213.000space.com');
  2. define('dbUser','space_4876282');
  3. define('dbPass','xxxx');;
  4. define('dbName','space_4876282_dbname');
  5.  
that's all sir..
i still wondering where is the differences connection setting that cause error in the login area x__x'

thank you sir for helping me..
Jan 15 '10 #17
dgreenhouse
250 Expert 100+
Haven't forgotten you... I'm just now going to bed... :-)
Jan 15 '10 #18
hi2..
hahah.. thank you sir..
sleep tight sir..

I've actually graduated yesterday
but I'm still curious about the above error ..
but I'll keep trying again to fix an error on the right

by the way thank you very much sir and sorry to bother you..
Jan 16 '10 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: D. K. | last post by:
Hi; I have installed suse 8.2 a short while ago and at my first attempt to connect mysql (via shell and a perl dbi script) i get following error: can't connect to mysql server through socjet...
0
by: Matthew Robinson | last post by:
i get this when i do '/etc/rc.d/rc.mysql start' ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2) ive had a look on google, and the problem for...
0
by: Ian | last post by:
Dear All, I just downloaded & installed MYSQL. It seemed to work and I can start it and enter my password and change a directory but that is about all. I have been ready and playing "hit & miss"...
3
by: Pugi! | last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get the following problem when connecting to mysql through a browser (phpMyAdmin): : #2002 Can't connect to local MySQL...
1
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
1
by: linux | last post by:
Sorry if this is a really dumb question. I am trying to connect to our remote MySQL server (which is running just fine). I have a perl script which worked just fine on my other Fedora 4 box (all...
2
by: Michal Stankoviansky | last post by:
Hi Environment: some version of Slackware, Apache 2.2.x, PHP 5.1.5, MySQL 5.0.24. The issue: I'm using Zend Framework Zend_Db component (which uses PDO). We have 2 mysql socket related...
2
by: hubcolyn | last post by:
i have just installed suse linux 10.0, when i run the command mysql -p, it prompts me for a password which i dont know so i press enter i get the following: error 2002 (HY000) cant connect to...
6
by: Christian | last post by:
Hi, Trying to connect to the MySQL server I get the classic error message ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) I have...
1
by: sasimca007 | last post by:
Hi friends, I installed mysql in ubuntu but, i don't know how to connect to that mysql. Actually we connect to postgresql by psql command, but when i tried to connect mysql with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.