|
-
Aug 1st, 2005, 04:58 AM
#1
[RESOLVED] MySQL in linux...
I am going to kill someone soon. I was first told that I had to compile MySQL from source, something I have never done before. Then I installed Apache and then PHP. But something was wrong with MySQL, so I was told that I could Apt-get it, something that is SOOO much easier. But will that work AFTER I have installed Apache2 and PHP4? I tried to follow VisualAds tutorial, even if it is for windows, but something must have gone wrong. When I get to the point where I am going to test to see if MySQL is working from PHP, and I use this script:
PHP Code:
<?php
$username = 'php';
$host = '.'; // this forces connection through a named pipe
$pw = 'secret';
if (! mysql_connect($host, $username, $pw)) {
die('Connection error: ' . mysql_error());
}
mysql_select_db('php_general');
$query = 'SELECT colname FROM test';
if (! $result = mysql_query($query)) {
die('Query error: ' . mysql_error());
}
?>
<html>
<head>
<title>Test Database Script</title>
</head>
<body>
<table>
<?php while($row = mysql_fetch_row($result)): // loop through all records?>
<tr>
<td><?php echo($row[0]) ?></td>
</tr>
<?php endwhile; ?>
</table>
</body>
</html>
I get an error on line 7 there, saying:
Warning: mysql_connect(): Unknown MySQL Server Host '.' (4) in /usr/local/apache/htdocs/phpmysql1.php on line 7
Connection error: Unknown MySQL Server Host '.' (4)
and if I try to change the host to anything else like local host, then I get this error:
Warning: mysql_connect(): Host 'localhost.localdomain' is not allowed to connect to this MySQL server in /usr/local/apache/htdocs/phpmysql1.php on line 7
Connection error: Host 'localhost.localdomain' is not allowed to connect to this MySQL server
Any idea about what I am not understanding here?
Thanks
- ØØ -
-
Aug 1st, 2005, 07:17 AM
#2
Re: MySQL in linux...
EDIT: That's what I get for not reading evberything.... I see yo udid try localhost... The other common error is not giving the username proper access. If I remember right, you can grant access to a username in general, as well as a username via specific domain (usualy in the form of username@localhost or some such.)
Did you use "localhost.localdomain" as the host, or just "localhost" byitself?
Tg
Last edited by techgnome; Aug 1st, 2005 at 07:20 AM.
-
Aug 1st, 2005, 07:47 AM
#3
Re: MySQL in linux...
 Originally Posted by techgnome
Did you use "localhost.localdomain" as the host, or just "localhost" byitself?
Tg
Do you mean in the PHP script? I tried both, because I saw that in my hosts file it had both, and even one more name that I tried (not sure if it is safe to post my hosts file, but lets try:
127.0.0.1 localhost.localdomain localhost PCDSUSI02
-
Aug 2nd, 2005, 03:26 AM
#4
Re: MySQL in linux...
Can you make a connection to the MySql server using yhte mysql client?
Have you tried entering the host as 127.0.0.1?
Have you set up permissions for localhost on the server?
-
Aug 2nd, 2005, 03:39 AM
#5
Re: MySQL in linux...
 Originally Posted by visualAd
Can you make a connection to the MySql server using yhte mysql client?
Hmmm..
If I am root, I can do this:
or
without password (don't think I have one yet.. )
mysql -h localhost -u root
or
mysql -h localhost -u php -D php_general -p
and I will get loged on...then I can querry the datbase as I want...And if I log in as php then I can only see this:
mysql> SHOW TABLES;
+-----------------------+
| Tables_in_php_general |
+-----------------------+
| test |
+-----------------------+
1 row in set (0.00 sec)
 Originally Posted by visualAd
Have you tried entering the host as 127.0.0.1?
Do you mean in the PHP script? Yeah I tried all of these:
127.0.0.1
localhost.localdomain
localhost
PCDSUSI02
If you mean as the url to the script, then yes, I have tried 127.0.0.1 too..
 Originally Posted by visualAd
Have you set up permissions for localhost on the server?
w00t.. ..not sure...how do I check...'
Thanks, love you by all my heart...
- ØØ -
-
Aug 2nd, 2005, 04:47 AM
#6
Re: MySQL in linux...
You are connecting with the username php. Have you set up and granted the php user the appropriate priviledges?
-
Aug 2nd, 2005, 04:56 AM
#7
Re: MySQL in linux...
quack.. ...when I made the user, I did as in your tutorial.
USE mysql;
GRANT ALTER,CREATE,DELETE,
DROP,INDEX,SELECT,INSERT ON php_general.*
TO 'php'@'localhost' IDENTIFIED BY 'secret';
FLUSH PRIVILEGES;
And as you can see I am able to log into the databse with the user php....isn't that enough?
- ØØ -
-
Aug 2nd, 2005, 05:16 AM
#8
Re: MySQL in linux...
I suspect you need to do the same for the user localhost.localdomain too as PHP appears to insist on giving that as a username.
-
Aug 2nd, 2005, 07:49 AM
#9
Re: MySQL in linux...
Name too long?
mysql> GRANT ALTER,CREATE,DELETE,
-> DROP,INDEX,SELECT,INSERT ON php_general.*
-> TO 'localhost.localdomain'@'localhost' IDENTIFIED BY 'secret';
ERROR 1145: The host or user argument to GRANT is too long
I also tried to add localhost:
mysql> GRANT ALTER,CREATE,DELETE,
-> DROP,INDEX,SELECT,INSERT ON php_general.*
-> TO 'localhost'@'localhost' IDENTIFIED BY 'secret';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
I was allowed to do it, not sure how smart it was..but it doesn't work though..
I even tried 'localhost'@'localdomain', guess that says it all about how lost I am now...
- ØØ -
-
Aug 2nd, 2005, 08:01 AM
#10
Re: MySQL in linux...
stranger....should 'root' automaticaly be able to use the database?
I tried this in my PHP file:
PHP Code:
$username = 'root';
$host = 'localhost'; // this forces connection through a named pipe
and this:
PHP Code:
$username = 'root';
$host = '.'; // this forces connection through a named pipe
But I still got the two same error messages.
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache/htdocs/phpmysql1.php on line 7
Connection error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Warning: mysql_connect(): Unknown MySQL Server Host '.' (4) in /usr/local/apache/htdocs/phpmysql1.php on line 7
Connection error: Unknown MySQL Server Host '.' (4)
Dumbedumbidum...
- ØØ -
-
Aug 2nd, 2005, 08:12 AM
#11
Re: MySQL in linux...
BTW, this step in your tutorial Visual:
To ensure PHP can find the MySql library we need to copy the file libmysql.dll (which can be found in the bin directory of the MySql root installation directory), to the windows directory. Either C:\winnt\ or C:\windows\
I might have skipped that one..hmmm...is there an equivalent thing in Linux?
- ØØ -
-
Aug 2nd, 2005, 09:45 AM
#12
Re: MySQL in linux...
Just out of curiosity, do you have a firewall setup? Is there any chance that that maybe blocking it?
Tg
-
Aug 2nd, 2005, 10:23 AM
#13
Re: MySQL in linux...
Not that I am aware of. This is a local test database. So I am not trying to reach it from the outside at all. So I didn't even think that it would be affected by any firewall.
But I guess there is some kind of firewall out of this company, but I can't change anything with that anyway. But don't think I have a software firewall. Unless it comes as a standard with Debian...
- ØØ -
-
Aug 2nd, 2005, 11:31 AM
#14
Re: MySQL in linux...
It won't be the firewall because it is a mysql error you are getting from the server, signifying that you made a connection.
Try granting all permissions to the user and see what you get:
Code:
GRANT ALTER,CREATE,DELETE,
-> DROP,INDEX,SELECT,INSERT ON php_general.*
-
Aug 3rd, 2005, 12:42 AM
#15
Re: MySQL in linux...
Do I have to be logged in as root? And isn't it missing a line there? The last one? And if I add it. Isn't it the same as I did in your tutorial:
USE mysql;
GRANT ALTER,CREATE,DELETE,
DROP,INDEX,SELECT,INSERT ON php_general.*
TO 'php'@'localhost' IDENTIFIED BY 'secret';
FLUSH PRIVILEGES;
Same permissions? On same database?
- ØØ -
-
Aug 3rd, 2005, 12:53 AM
#16
Re: MySQL in linux...
Sorry, I meant to write this:
Code:
GRANT ALL ON php_general.* ....
The rest of the query is the same.
-
Aug 3rd, 2005, 02:47 AM
#17
Re: MySQL in linux...
Hmmm....still the same error message. But the interesting thing, is that I changed the hosts file to this:
127.0.0.1 pcdsusi02.cern.ch pcdsusi02
And if I know try to log on as 'php' to the host 127.0.0.1, then it gives me this message:
Warning: mysql_connect(): Host 'pcdsusi02.cern.ch' is not allowed to connect to this MySQL server in /usr/local/apache/htdocs/phpmysql1.php on line 7
Connection error: Host 'pcdsusi02.cern.ch' is not allowed to connect to this MySQL server
Does that tell anyone anything..
- ØØ -
-
Aug 3rd, 2005, 03:01 AM
#18
Re: MySQL in linux...
Break through?
When I run phpinfo(), it gives me this info about the .configure command:
'./configure' '--with-mysql=/home/noteme/mydoc/mysql-standard-4.0.25-pc-linux-gnu-i686' '--with-xml' '--enable-track-vars' '--with-apxs2=/usr/local/apache/bin/apxs'
But that is not the mysql I am using now. That is the one I tried to compile from source (read first post), and not the one I apt-geted. So I guess I should try to compile the php module again, with the right parameter then? If so, should I uninstall something first? Or should I start from scratch or?
BTW what should the parameter be? When I use apt-get it installs things all over the place..
PCDSUSI02:/# f mysql
./etc/init.d/mysql
./etc/mysql
./var/lib/mysql
./var/lib/mysql/mysql
./var/cache/mysql
./var/log/mysql
./usr/share/mysql
./usr/bin/mysql
./usr/lib/perl5/auto/DBD/mysql
./usr/lib/perl5/DBD/mysql
./home/noteme/mydoc/apps/php-4.4.0/ext/mysql
./home/noteme/mydoc/mysql-standard-4.0.25-pc-linux-gnu-i686/bin/mysql
./home/noteme/mydoc/mysql-standard-4.0.25-pc-linux-gnu-i686/share/mysql
./home/noteme/mydoc/mysql-standard-4.0.25-pc-linux-gnu-i686/data/mysql
./home/noteme/mydoc/mysql-standard-4.0.25-pc-linux-gnu-i686/mysql
The yellow ones I am at least sure is the old files, the red one I am 100% sure is the new one, not sure about the rest. So what should that parameter point at? The mysql "binary" file?
- ØØ -
-
Aug 3rd, 2005, 07:24 AM
#19
Re: MySQL in linux...
Hmmmm..... I wonder since it looks like it is pointing to two different instances of MySQL, it doesen't know where to go ..... ????
Grasping at straws here....Here's what I'm thinking, make a copy of the config file.... and remove the yellow lines (since you think the red one is the right one). Restart everything and then see if it works. If it doesn't then swap out the red line for the yellow ones, and restart.
???
Tg
-
Aug 3rd, 2005, 07:42 AM
#20
-
Aug 3rd, 2005, 08:33 AM
#21
Re: MySQL in linux...
Ah, OK.... I see that now... -pops eyeballs out & gives them a good cleannin'-
there should be a httpd.conf file .... I think that is what holds the link to what mySQL to use....
Honestly... you got me.... I don't know why this stuff is so difficult sometimes... it's like you have to be a rocket scientist to figure it all out. And there are some many ways to do it that any one little thing can screw it all up.
Tg
-
Aug 3rd, 2005, 08:58 AM
#22
Re: MySQL in linux...
Is it supposed to be anything about MySQL in the httpd.conf file..? Hmm...if so..oops? The only thing I have added is this:
# mod_python
LoadModule python_module /usr/local/apache/modules/mod_python.so
<Directory /usr/local/apache/htdocs/test>
AddHandler mod_python .py
PythonHandler test
PythonDebug On
</Directory>
### PHP Configuration
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
-
Aug 3rd, 2005, 09:28 AM
#23
Re: MySQL in linux...
Just recompile PHP with the new MySql sources. That seems to be the most plausable explanation for the problem.
-
Aug 3rd, 2005, 09:49 AM
#24
Re: MySQL in linux...
Looks like the new install doesn't have the header files. Found out that I could do:
'locate mysql.h'
to find out where they are, and that only gave me paths to the old mysql and the PHP folder. But if I don't write the path to the headerfiles, then it says that things like mod_perl won't work...so then I am guessing that mod_python won't work..
-
Aug 3rd, 2005, 09:50 AM
#25
-
Aug 22nd, 2005, 07:23 AM
#26
Re: [RESOLVED] MySQL in linux...
I soooooooooooo can't belive this....what is wrong with me....I managed to get this work before I went on a vecation, and then I leave for a vecation and when I get back it doesn't work anymore...and no one as far as I know have used my computer...w00000t....I can't even log on to mysql using command line:
PCDSUSI02:/# mysql
ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
PCDSUSI02:/# ./usr/sbin/mysqld
050822 14:25:25 ./usr/sbin/mysqld: unknown variable 'old_passwords=1'
Do I really need to start to cry? Any idea?
Last edited by NoteMe; Aug 22nd, 2005 at 07:27 AM.
-
Aug 22nd, 2005, 08:07 AM
#27
Re: [RESOLVED] MySQL in linux...
To make a long story short. There must have been an upgrade on my system, so a never version of mysql-server must have been installed. That made one of the config files buggy. So I had to find this file:
/etc/mysql/my.cnf
and comment out this line:
old_passwords=1
and now everything seems to work again...life is mint..
- ØØ -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|