Results 1 to 27 of 27

Thread: [RESOLVED] MySQL in linux...

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved [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
    - ØØ -

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: MySQL in linux...

    Quote 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

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: MySQL in linux...

    Quote 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:
    mysql
    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)


    Quote 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..


    Quote 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...
    - ØØ -

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: MySQL in linux...

    You are connecting with the username php. Have you set up and granted the php user the appropriate priviledges?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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?

    - ØØ -

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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...


    - ØØ -

  10. #10

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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...
    - ØØ -

  11. #11

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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?


    - ØØ -

  12. #12
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: MySQL in linux...

    Just out of curiosity, do you have a firewall setup? Is there any chance that that maybe blocking it?

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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...


    - ØØ -

  14. #14
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.*
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  15. #15

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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?

    - ØØ -

  16. #16
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: MySQL in linux...

    Sorry, I meant to write this:
    Code:
    GRANT ALL ON php_general.* ....
    The rest of the query is the same.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  17. #17

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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..


    - ØØ -

  18. #18

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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?


    - ØØ -

  19. #19
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  20. #20

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: MySQL in linux...

    What config file? The list with the yellow and red lines was just made doing a search on my HDD for the name "mysql"..

    But if I write "which mysql" I can see that it is calling the one with the red line there....so that is how I know that...


    - ØØ -

  21. #21
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  22. #22

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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

  23. #23
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: MySQL in linux...

    Just recompile PHP with the new MySql sources. That seems to be the most plausable explanation for the problem.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  24. #24

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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..

  25. #25

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: MySQL in linux...

    Ignore the last post.....it is OMG working.:..no idea why..since they say it won't work, but I can manage to both reach MySQL through PHP and use mod_python...I am so in love with you two guys....seriously..::

    Thanks a million and a half......
    - ØØ -


    [Edit] And of course I am not able to give reps to anyone of you..grrr...well at least bookmarked...will give it an other time when I can...that is for sure...I am so going to drink a lot of beer tonight after I (or you) managed to make this work..

  26. #26

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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.

  27. #27

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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
  •  



Click Here to Expand Forum to Full Width