
|
View Full Version : MySQL on Raq4
Whitesell 03-04-2002, 12:18 PM Hi All,
I've got PHP4 and MySQL running on my Raq4 and am just beginning to try to use MySQL. I'm running into a problem connecting to the databases with PHP.
I'm sure there is an easy fix, but since I'm brand new to MySQL I haven't been able to figure it out yet. Here's what's happening:
I can log in and create databases and build tables via telnet. I installed phpMyAdmin and got it running, but I had to define the path to the socket in config.inc.php as follows:
$cfgServers[1]['socket'] = '/var/lib/mysql/mysql.sock';
Every time MySQL tries to connect to a database I get the following error:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)
It's obvious PHP can't find the socket where it expects it. The question I have is How do I move the socket to the location that is expected by php? Or is there a way to define the path to the socket in PHP?
I'm really new to both PHP and MySql, so I'm afraid I'll probably need a clear step-by-step instruction in order for it to sink in to my thick skull!
Thanks in advance for your help!
Regards,
Jim
P.S. What would be a good beginner's book for PHP and MySQL??
GideonX 03-04-2002, 01:26 PM why not just change this:
$cfgServers[1]['socket'] = '/var/lib/mysql/mysql.sock';
to
$cfgServers[1]['socket'] = '/tmp/mysql.sock';
err...hope that would work :)
edit - u may also wish to do a locate on your mysql.sock..
Whitesell 03-04-2002, 01:39 PM why not just change this:
$cfgServers[1]['socket'] = '/var/lib/mysql/mysql.sock';
to
$cfgServers[1]['socket'] = '/tmp/mysql.sock';
When I fist tried to run phpMyAdmin, I got the same error. The docs include this:
[QUOTE]First, you need to determine what socket is being used by MySQL.
To do this, telnet to your server and go to the MySQL bin directory. In this directory there should be a file named mysqladmin. Type ./mysqladmin variables, and this should give you a bunch of info about your MySQL server, including the socket (/tmp/mysql.sock, for example).
Then, you need to tell PHP to use this socket.
Assuming you are using PHP 3.0.10 or better, you can specify the socket to use when you open the connection. To do this in phpMyAdmin, you need to complete the socket information in the config.inc.php3.
[QUOTE]
When I looked at the variables per the above instructions, I found that it is using 'var/lib/mysql/mysql.sock', not '/tmp/mysql.sock', which is what PHP wants to use. So even though I've got phpMyAdmin working, other attempts to connect via php are failing becuse it is trying to find the socket at /tmp/mysql.sock.
Regards,
Jim Whitesell
ctorrington 03-04-2002, 01:46 PM Out of interest, how did you install PHP and MySQL because i just compiled both of them and they just magically worked.
Whitesell 03-04-2002, 01:53 PM They were both installed on the server when I got it. I've had the server a little over a year, but haven't tried to use MySql until now. I've got a couple of clients wanting to use it but I need to get this figured out first!
Regards,
Jim Whitesell
ctorrington 03-04-2002, 01:56 PM I would suggest installing PHP again so that it can find mysql.
Cephren 03-04-2002, 02:06 PM You'll need:
1. MySQL 3.23.37 pkg file
- http://pkg.nl.cobalt.com/i386/RaQ3-RaQ4-MySQL-3.23.37-1.pkg
2. PHP 4.06 source tarball
- http://www.php.net/do_download.php?download_file=php-4.0.6.tar.gz&source_site=www.php.net
3. PHPinfo config settings.
- Create a php file named phpinfo.php and place in it
<? phpinfo(); ?>
Load that up in your browser and look for the Configure command settings
i.e. http://yourdomain.com/phpinfo.php
Remove the single quotes and you'll find for Rackshack.net raq4i server like i have the following:
quote:
--------------------------------------------------------------------------------
./configure --prefix=/usr --with-apxs=/usr/sbin/apxs --with-gd --with-gettext=/usr --enable-safe-mode --with-config-file-path=/etc/httpd --with-exec-dir=/usr/bin --with-zlib --enable-magic-quotes --with-regex=system --with-ttf=/usr/lib/libttf.so --enable-track-vars --enable-xml --disable-debug --with-db3 --with-interbase=shared --with-pgsql=shared --with-ldap --with-imap
--------------------------------------------------------------------------------
Notice: that --with-mysql has not been compiled into php 4.03, you'll need to add this for php 4.06 (further below) as well as change --with-db3 to --with-db
Install MySQL
====================
1. Log into raq4 server admin page and go to ->Maintenance ->Install software
Enter the pkg file url at http://pkg.nl.cobalt.com/i386/RaQ3-RaQ4-MySQL-3.23.37-1.pkg
and hit install and wait for confirmation of install at the bottom frame of the page.
2. Now to change the mysql root password to secure your mysql server
- log in telnet
- switch to root user
su -
- type
mysqladmin -uroot -pcobalt-mysql password NEW-PASSWORD
Upgrade PHP 4.03 to PHP 4.06 (with mysql support)
=========================================================
This will upgrade PHP 4.03 to PHP 4.06 with mysql support.
1. telnet into your server
2. switch to root user
su -
3. change to /usr/local/src directory
cd /usr/local/src
4. Download php 4.0.6 source tarball:
wget http://www.php.net/do_download.php?download_file=php-4.0.6.tar.gz&source_site=www.php.net
5. extract tarball
tar xfz php-4.0.6.tar.gz
6. change to php-4.0.6 directory
cd php-4.0.6
7. Copy and paste this new configure command line. Get the configure command line from above in phpinfo.php page and you'll need to add --with-mysql as well as change --with-db3 to --with-db so it looks like (i use a text file to hold this configure command so i can copy and paste it):
quote:
--------------------------------------------------------------------------------
./configure --prefix=/usr --with-mysql --with-apxs=/usr/sbin/apxs --with-gd --with-gettext=/usr --enable-safe-mode --with-config-file-path=/etc/httpd --with-exec-dir=/usr/bin --with-zlib --enable-magic-quotes --with-regex=system --with-ttf=/usr/lib/libttf.so --enable-track-vars --enable-xml --disable-debug --with-db --with-interbase=shared --with-pgsql=shared --with-ldap --with-imap
--------------------------------------------------------------------------------
8. type
make
9. now backup the .so files that are currently in use
mkdir backup_so
mkdir backup_so/php
cp /etc/httpd/modules/libphp4.so ./backup_so/
cp /etc/httpd/modules/php/* ./backup_so/php/
10. type
make install
11. restart apache
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start
12. check your http://yourdomain.com/phpinfo.php you should have PHP 4.06
blacknight 03-04-2002, 02:27 PM Wouldn't it be easier for him to install everything using the latest packages?
There's also a very nice package version of PhPMyAdmin available from Cobalt World (http://www.cobaltworld.com/)
ctorrington 03-04-2002, 02:54 PM Yes, as far as I can see just by looking at it, the above steps are sound. But just use PHP 4.1.2 instead of 4.0.6
Whitesell 03-04-2002, 04:23 PM Thanks, guys, for your help!
After re-installing both, php is now able to connect with MySQL!
By the way, the cobalt pkg site has been shut down. They have spun the site off to:
http://pkgmaster.com
dlyles 03-05-2002, 11:14 PM Ok, I need to jump in here because I'm having a 'similar' problem. I'm getting the message "Error 2002 can't connect to MySQL server through socket /var/lib/mysql/mysql.sock"
I don't know what to do to fix this problem. The problem started when I did two things - 1 - I removed a .pid file (don't know what that is) and 2- upgraded to ChiliASP 3.6. Before that, I was able to connect. Any help or even a place to go for the answer would be GREATLY appreciated.
Whitesell 03-06-2002, 01:02 AM Hi dlyles,
Are you having this problem with PHP? If so, you can check to see what socket PHP is using by doing the following:
1. Create a file called phpinfo.php. This file only needs one line in it:
<? phpinfo(); ?>
2. Upload that file to your server and look at in in your browser:
http://www.yourdomain.com/phpinfo.php
3. It'll print out a bunch of details Under 'mysql' you'll see if support is enabled. look for the entry 'MYSQL_SOCKET' and check to see what the value is.
In my case, it was wrong. Re-installing mysql did the trick for me.
Hope this helps,
Jim Whitesell
dlyles 03-06-2002, 01:17 AM I'm not using PHP. Thanks for the input anyway. I did try reinstalling and reinstalling again, but that didn't work.
jahsh 03-07-2002, 08:37 PM all you need to do is make a soft link:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
and that should fix your problem.:stickout
nolittle 04-12-2002, 04:25 PM This may be a bit late. I have just joined this forum. I am also learning PHP and MySQL.
Re a book recommendation. I have found "PHP and MySQL Web Development" by sams to be quite good
Alan
|