LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 01-06-2010, 01:07 AM   #1
liuguobiao
Member
 
Registered: Dec 2008
Location: china
Distribution: slackware
Posts: 32

Rep: Reputation: 16
Unhappy zend server can't connect mysql


Hi ,I have got a trouble in conneting mysql.

I am using slackware12.2, I have a mysql5.0.67 which system has install for me and I had install a zend server4.0.6 from http://www.zend.com/products/server/, It runs all right .When I try to run my php code in zend server(apache),it break out an error with connect to mysql.
But when I login mysql in command line ,I can see all my databases what my codes need in it.
The code was running well in windows. I try to build the zend+mysql+php environment several times in linux but never success。
how can I do to let it runs all right ? some one said I can edit php.ini, It's it right ? how can I do ?
I try my best to express my trouble, Wait for your help .

Last edited by liuguobiao; 01-06-2010 at 01:11 AM.
 
Old 01-06-2010, 08:57 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by liuguobiao View Post
Hi ,I have got a trouble in conneting mysql.

I am using slackware12.2, I have a mysql5.0.67 which system has install for me and I had install a zend server4.0.6 from http://www.zend.com/products/server/, It runs all right .When I try to run my php code in zend server(apache),it break out an error with connect to mysql.
But when I login mysql in command line ,I can see all my databases what my codes need in it.
The code was running well in windows. I try to build the zend+mysql+php environment several times in linux but never success。
how can I do to let it runs all right ? some one said I can edit php.ini, It's it right ? how can I do ?
I try my best to express my trouble, Wait for your help .
You don't post any of the code, actual error messages, or give any details, how can you expect anyone to help?

Provide details, error(s), etc., and we can try. Right now, chances are good that your code is not passing the right parameters to make the MySQL connection, or that you haven't installed the php-mysql modules.
 
1 members found this post helpful.
Old 01-06-2010, 09:11 PM   #3
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
Can you connect to mysql with straight PHP (not using zend)?
 
1 members found this post helpful.
Old 01-07-2010, 12:10 AM   #4
liuguobiao
Member
 
Registered: Dec 2008
Location: china
Distribution: slackware
Posts: 32

Original Poster
Rep: Reputation: 16
thanks for you. I didn't show the errors because the errors are too long .Here is the error:
Code:
Exception information:

Message: _connect() 
#1 /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Abstract.php(448): Zend_Db_Adapter_Pdo_Mysql->_connect() 
#2 /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE `divis...', Array) 
#3 /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Mysql.php(156): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `divis...') 
#4 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(823): Zend_Db_Adapter_Pdo_Mysql->describeTable('division', NULL) 
#5 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(866): Zend_Db_Table_Abstract->_setupMetadata() 
#6 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(973): Zend_Db_Table_Abstract->_setupPrimaryKey() 
#7 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Select.php(100): Zend_Db_Table_Abstract->info() 
#8 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Select.php(78): Zend_Db_Table_Select->setTable(Object(Default_Model_DbTable_Division)) 
#9 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(1009): Zend_Db_Table_Select->__construct(Object(Default_Model_DbTable_Division)) 
#10 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(1307): Zend_Db_Table_Abstract->select() 
#11 /dream/workplace/server/cnadev/application/modules/default/controllers/IndexController.php(21): Zend_Db_Table_Abstract->fetchAll() 
#12 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Action.php(513): IndexController->indexAction() 
#13 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('indexAction') 
#14 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) 
#15 /usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch() 
#16 /usr/local/zend/share/ZendFramework/library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run() 
#17 /dream/workplace/server/cnadev/web/index.php(29): Zend_Application->run() #18 {main}->getMessage() ?>
Stack trace:

_connect()
#1 /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Abstract.php(448): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE `divis...', Array)
#3 /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Mysql.php(156): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `divis...')
#4 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(823): Zend_Db_Adapter_Pdo_Mysql->describeTable('division', NULL)
#5 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(866): Zend_Db_Table_Abstract->_setupMetadata()
#6 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(973): Zend_Db_Table_Abstract->_setupPrimaryKey()
#7 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Select.php(100): Zend_Db_Table_Abstract->info()
#8 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Select.php(78): Zend_Db_Table_Select->setTable(Object(Default_Model_DbTable_Division))
#9 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(1009): Zend_Db_Table_Select->__construct(Object(Default_Model_DbTable_Division))
#10 /usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(1307): Zend_Db_Table_Abstract->select()
#11 /dream/workplace/server/cnadev/application/modules/default/controllers/IndexController.php(21): Zend_Db_Table_Abstract->fetchAll()
#12 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Action.php(513): IndexController->indexAction()
#13 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('indexAction')
#14 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#15 /usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
#16 /usr/local/zend/share/ZendFramework/library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run()
#17 /dream/workplace/server/cnadev/web/index.php(29): Zend_Application->run()
#18 {main}->getTraceAsString() ?>
as abefroman said ,I write a php file to connect mysql:
Code:
<?php
$link=mysql_connect('localhost','root','123456'); 
echo "link = ".$link;
and I found the $link is empty. So I think what TB0ne has said was right :I haven't installed the php-mysql modules. I didn't know whether it been installed or not beacause I just type './install.sh' to install zend server for linux.

If I want to install php-mysql modules in zend now what can I do ?
 
Old 01-24-2010, 02:24 AM   #5
karnaf
Member
 
Registered: Dec 2005
Distribution: Linux Mint 14 (Cinnamon), Xubuntu 12.04, Ubuntu 10.04
Posts: 49

Rep: Reputation: 15
As far as I know, MySQL extension is installed by default with Zend Server.
You can check that by logging into the Zend Server UI (probably http://localhost:10081 on your machine) and going to Server Setup | Extensions. Look for it there and see if it is on.

I assume it is loaded, otherwise you would have gotten a
Code:
Fatal error:  Call to undefined function mysql_connect() in /var/www/yourpage.php on line ...
I suggest you add some more verbosity to your code, e.g.

Code:
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);

$link=mysql_connect('localhost','root','123456'); 
if (false === $link) {
    echo mysql_error();
} else {
    echo 'link = ' . $link;
}
which may help you understand what the problem is.

May I also suggest switching to PDO? much safer and easier to handle

Cheers,
karnaf
 
Old 01-25-2010, 12:45 AM   #6
liuguobiao
Member
 
Registered: Dec 2008
Location: china
Distribution: slackware
Posts: 32

Original Poster
Rep: Reputation: 16
HI
karnaf I get a error with your code:
Code:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /dream/workplace/server/mysql.php on line 5 Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
This is a simple error ,I run command line :
Code:
sudo ln -s /var/run/mysql/mysql.sock /tmp/mysql.sock
Then it run all right with you code.
But in my code .It has error with the same Exception information I have show.
Here is my IndexController.php file ( just show important code ):
Code:
<?php
class IndexController extends Zend_Controller_Action {
	public function init() {
		/* Initialize action controller here */
	}	
	public function indexAction() {
		$division = new Default_Model_DbTable_Division ( );
 //class Default_Model_DbTable_Division is extends from 
the class Zend_Db_Table_Abstract
		$type1 = $division->fetchAll ();

		echo "good";exit(1);

		$type2 = array ();
		foreach ( $type1 as $row ) {
			$type2 [$row->divisionID] = $row->type;
		}
	        $this->view->type2 = $type2;
	}
}
( Reiterate That my code were running well in windows + zend + mysql )
With my test ,I found the code stop in the line "$type1 = $division->fetchAll ();"
The line just to fetch all data from database.
I can sure ,These error are with MYSQL , But I can't found what 's wrong with it. I google it ,but few people meet this problem or some body ask but there are no people reply him ...
Trying.......and Waiting .....

Last edited by liuguobiao; 01-25-2010 at 12:47 AM.
 
  


Reply

Tags
mysql, server



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
help with zend core php + mysql, cannot connect. yandos Linux - Server 4 12-12-2008 01:44 AM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 03:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:27 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration