Find the answer to your Linux question:
Results 1 to 10 of 10
Apache is up and running and can parse php files properly. MySQL is running properly and I can run SQL queries from the CLI but I can't seem to get ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Location
    Aberdeen, Scotland
    Posts
    64

    MySQL and phpMyAdmin


    Apache is up and running and can parse php files properly.

    MySQL is running properly and I can run SQL queries from the CLI but I can't seem to get PHP and MySQL to function together.

    I've tried connecting to the DB from my own script and it gives the same error as when phpMyAdmin tries to connect...

    Code:
    phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.
    The login and host details are correct to the best of my knowledge... Any ideas what might be going on?

  2. #2
    Just Joined!
    Join Date
    Jan 2006
    Posts
    35
    can you post your script?

    Im gonna give u a basicscript how you can check if your database is accessible.
    <?php
    $db_host = "localhost";
    $db_username = "root";
    $db_password = "";

    $err= "Fault while connecting!";
    $db_connectie = mysql_connect($db_host, $db_username, $db_password) or die($err); // connect to database, if fail -> show error
    ?>
    Try this script and fill in the good values for $db_host $db_username and $db_password. I think if u didn't change anything the standard password for the user "root" is "" (empty).

    The useraccounts from mysql have nothing to do with those from anything else.

    Try this. If u can login with the username "root" and password "", you can then configure your phpMyAdmin. After that you can access your database and add users. IMPORTANT!!! Be shure to change the password for the root account. And change the settings in the config file of phpMyAdmin.
    Further... Dont let your scripts use the root account. Its very unsafe.

    I hope this helps.

  3. #3
    Just Joined!
    Join Date
    Jan 2006
    Posts
    71
    You may have to edit your php.ini file if you didnt compile php with mysql support.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Aug 2005
    Location
    Aberdeen, Scotland
    Posts
    64
    Quote Originally Posted by root@localdomain
    can you post your script?

    Im gonna give u a basicscript how you can check if your database is accessible.
    <?php
    $db_host = "localhost";
    $db_username = "root";
    $db_password = "";

    $err= "Fault while connecting!";
    $db_connectie = mysql_connect($db_host, $db_username, $db_password) or die($err); // connect to database, if fail -> show error
    ?>
    Try this script and fill in the good values for $db_host $db_username and $db_password. I think if u didn't change anything the standard password for the user "root" is "" (empty).

    The useraccounts from mysql have nothing to do with those from anything else.

    Try this. If u can login with the username "root" and password "", you can then configure your phpMyAdmin. After that you can access your database and add users. IMPORTANT!!! Be shure to change the password for the root account. And change the settings in the config file of phpMyAdmin.
    Further... Dont let your scripts use the root account. Its very unsafe.

    I hope this helps.
    Hi, and thanks!

    This script simply returns 'Fault while connecting!'. Any more ideas?

  6. #5
    Linux User stokes's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    274
    Create a new file called test.php, and insert this code:

    Code:
    <? phpinfo(); ?>
    Then place the file in your document root and open it. Then can you post a link or a copy & paste of the info here?
    Registered Linux user #389109
    My Semi-Linux Blog

  7. #6
    Just Joined!
    Join Date
    Aug 2005
    Location
    Aberdeen, Scotland
    Posts
    64
    It was too long but I think the bit's you are looking for are...

    Code:
    PHP Version 5.1.1
    
    Configure Command 	 './configure' '--prefix=/usr' '--with-apxs2=/usr/sbin/apxs' '--enable-force-cgi-redirect' '--enable-discard-path' '--enable-fastcgi' '--with-config-file-path=/etc/apache' '--enable-safe-mode' '--with-openssl=/usr' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--with-curlwrappers' '--enable-dba' '--with-gdbm=/usr' '--with-db4=/usr' '--with-inifile' '--with-flatfile' '--enable-dbase' '--with-libxml-dir=/usr' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-openssl-dir=/usr' '--with-gd' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--with-t1lib=/usr' '--enable-gd-native-ttf' '--enable-gd-jis-conv' '--with-gettext=shared,/usr' '--with-gmp=/usr' '--enable-mbstring' '--with-libmbfl' '--with-mhash=/usr' '--with-mysql=shared,/usr' '--with-mysql-sock=/var/run/mysql' '--with-zlib-dir=/usr' '--enable-embedded-mysqli' '--with-ncurses=/usr' '--enable-shmop' '--with-libxml-dir=/usr' '--enable-soap' '--with-libxml-dir=/usr' '--enable-sockets' '--enable-sqlite-utf8' '--with-regex=php' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--with-libxml-dir=/usr' '--with-xmlreader' '--with-libxml-dir=/usr' '--with-pear' '--with-zend-vm=CALL' '--with-tsrm-pthreads' '--enable-shared' '--enable-static' '--program-prefix=' '--program-suffix='
    
    mysql
    MySQL Support	enabled
    Active Persistent Links 	0
    Active Links 	0
    Client API version 	5.0.18
    MYSQL_MODULE_TYPE 	external
    MYSQL_SOCKET 	/var/run/mysql/mysql.sock
    MYSQL_INCLUDE 	-I/usr/include/mysql
    MYSQL_LIBS 	-L/usr/lib -lmysqlclient
    
    
    Directive	Local Value	Master Value
    mysql.allow_persistent	On	On
    mysql.connect_timeout	60	60
    mysql.default_host	no value	no value
    mysql.default_password	no value	no value
    mysql.default_port	no value	no value
    mysql.default_socket	no value	no value
    mysql.default_user	no value	no value
    mysql.max_links	Unlimited	Unlimited
    mysql.max_persistent	Unlimited	Unlimited
    mysql.trace_mode	Off	Off

  8. #7
    Just Joined!
    Join Date
    Jan 2006
    Posts
    4
    Could this be a firewall issue? Maybe you might need to open a few ports. I've experienced this but I can't remember if it gave me the same message.

  9. #8
    Just Joined!
    Join Date
    Aug 2005
    Location
    Aberdeen, Scotland
    Posts
    64
    Quote Originally Posted by Lucidity
    Could this be a firewall issue? Maybe you might need to open a few ports. I've experienced this but I can't remember if it gave me the same message.
    I thought this but I have tried this solution and it didn't help. I opened port 3308 on my router (Virtual Servers) and it didn't help at all. I'm not running the Linux Firewall because I have a hardware firewall. I'm not too sure if the computer even has to put a request outside of my network.

  10. #9
    Just Joined!
    Join Date
    Jan 2006
    Posts
    35
    lol

    sorry but I think you are searching to far.
    First try the script I gave you.
    or use this, its a bit modified, it now shows the error php gives when it tries to connect to the mysql database.

    <?php
    $db_host = "localhost";
    $db_username = "root";
    $db_password = "";

    $db_connectie = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); // connect to database, if fail -> show error
    ?>

    If this gives an error, you know it cant connect to the mysql database.
    Be shure to check that there is an mysql account for the user and password and host you provided with $db_host $db_username $db_password.
    If you want help with this ask me.
    Be shure you started the mysql server.
    Then try what Bailz said.
    Also, maybe it is good to try "iptables -F".It will flush your firewall rules.
    Then try agian. I searched 5hours to solve a problem because of I thought the firewall was shutted down.

    If you want more help, also ask me.

  11. #10
    Just Joined!
    Join Date
    Aug 2005
    Location
    Aberdeen, Scotland
    Posts
    64
    Quote Originally Posted by root@localdomain
    Then try what Bailz said.
    It's Bailz that is having the trouble!

    I ran this code:
    Code:
    	$connect = mysql_connect('127.0.0.1','root','');
    	echo "<b>Connect Result: </b>";
    	if($connect){
    		echo "I've connected...";
    	} else {
    		echo "Could not connect: " . mysql_error();
    		$ping = mysql_ping('127.0.0.1');
    		echo "<br /><b>Ping Results: </b>";
    		if($ping){
    			echo "Database is there...";
    		} else {
    			echo "Database is <b>not</b> there...";
    		}
    	}
    It says the the connection to the server was lost during the query and the ping function says that the server is not there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •