How do i connect MySQL with PHP?

Discussion in 'Web Design and Development' started by xper, Aug 28, 2009.

  1. xper macrumors 6502

    xper

    Joined:
    Dec 15, 2005
    Location:
    Sweden - Halmstad
    #1
    Hi!

    I don´t like MAMP anymore and since Apache and PHP ships with OS X i want to use those!

    I downloaded cummunity server, latest beta, on mysql.com, installed it fine and it shows up in pref!

    The problem now is that PHP must know where to connect to MySQL and the documentation on mysql.com is longer than the bible and describes how to hike in the andeés 120% more than they talk about mysql.

    Anywhay, MySQL is now installed on /usr/Local/MySQL and PHP god knows where.

    Anyone that can guide me?
     
  2. Joined:
    Jun 30, 2009
    #2
    I strongly suggest you use MAMP, it's way easier, and the reason you're not currently doing it does not make any sense, most probably.

    Anyway, if you're looking for a script, here it is:
    PHP:
    mysqli_connect('host''username''password''database_name''port''socket');
    For example, for MAMP's MySQL settings:
    PHP:
    mysqli_conenct('localhost''root''root''test''8889''/Applications/MAMP/tmp/mysql/mysql.sock');
    You can also always check PHP's official documentation
     
  3. xper thread starter macrumors 6502

    xper

    Joined:
    Dec 15, 2005
    Location:
    Sweden - Halmstad
    #3
    Well, the term "anymore" means that i have used and use it currently but i dont want to use it anymore, and i need to know how to install mysql for future deplyment!

    I am not looking for a script, i know how to connect to a DB but for that to work i need a DB to connect to, i need to specify something in php.ini so php know where mysql is located and stuff
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    Something like this (php.ini),

    Code:
    mysql.default_socket = /tmp/mysql.sock
     
  5. xper thread starter macrumors 6502

    xper

    Joined:
    Dec 15, 2005
    Location:
    Sweden - Halmstad
    #5
    Great, thank you!

    It works now but i am having one more problem, i am only allowed to upload a 2mb SQL file through phpMyAdmin and my SQL file is alot bigger then (that?), where is the MySQL config located? I only find config.huge.ini, config.medium.ini and so on but how do i know which is activated?
     
  6. xper thread starter macrumors 6502

    xper

    Joined:
    Dec 15, 2005
    Location:
    Sweden - Halmstad
    #7
    Well, it seems like i dont have a file called my.cnf, looked in every relative folder and searched for it but no luck :S
     
  7. savar macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #8
    Open terminal, and try:

    sudo locate.updatedb

    then:

    locate my.cnf
     

Share This Page