# Über n00b setting up PHP and MySQL - shell syntax problem?



## midazolam (Mar 16, 2005)

Hi everyone,

*Here's where I'm at so far:*

I have d/l and installed the PHP module from Mark Liyanage (http://www.entropy.ch/software/macosx/php/).

I have d/l and installed the MySQL pkg file from MySQL.com (the one for OSX)

I have been following a tutorial on MacWorld's site that I remembered reading a while ago: http://www.macworld.com/2002/11/features/database/

*Here's what IS working:*

PHP is installed and running - accessing the test.php file I created gives me the page Mark says it will on his site (also in the MacWorld tut).

MySQL is installed and the PrefPane says it is running. (Startup item was also installed)

*Here is the problem:*

In the Macworld Tutorial (and others I've seen online), you set up your password in the config.inc.php file, which I did.  I also set up the _$cfg['Servers'][]['auth_type'] = 'config';_ line to read "http" between the single quotes.  When I try to connect to MySQL through PHP MyAdmin it says the password is incorrect.  So back to the MacWrold tut, it says to set your password in MySQL by typing the command:
_rehash; mysqladmin -u root password newpassword_
where _newpassword_ is the password that you put in the config file.  Problem is, this tut was written when the shell was tcsh and not bash.  bash doesn't like the rehash command, and hash doesn't work properly with the commands that follow it.

First thing I tried was to try what they suggest in the MacWorld tut to test and see if the MySQL install really _was_ running, and went to Terminal and typed _mysql -u root -p_.  Password _still_ doesn't work.

Suggestions?

Thanks in advance for taking time to read this!

:m


----------



## michaelsanford (Mar 16, 2005)

I see from that confic.inc.php linethat you're using phpMyAdmin ? It's usually a good idea to include information like that, because it's in fact (probably) not MySQL that not working properly, but phpMyAdmin.

Did you change your root mysql password when you installed it ? If you used the .pkg installer (which is IMO the way to go on OS X) you won't have. MySQL keeps its passwords in its own database, so it WON'T be the same as your Mac OS X "root" users password.

Try logging in in the Terminal like this
*mysql -u root* (without the -p)

If that works then you have your problem. Type this then in the terminal (to change your root password, note that the first 'password' there is not your current password but is a command, the second one in quotations marks IS a new password):
*mysqladmin -u root password 'mynewpassword'*


----------



## midazolam (Mar 16, 2005)

Hey Michael - thanks for your reply.

I *did* change the password in th config file to what I wanted it to be, but still no dice.

I just tried your suggestion of logging in to MySQL without the password, and I get the following:

_-bash: mysql: command not found_

I did install MySQL using a .pkg installer and if the PrefPane is any indication, the install DID work.  I should also mention that I am running the latest version of OS X (10.3.8) with all of the latest updates.

Thanks for your help so far and hopefully you'll have some insight as to what's happening here.

:m


----------



## michaelsanford (Mar 16, 2005)

When you say " I *did* change the password in th config file to what I wanted it to be" you mean in config.inc.php ?


----------



## midazolam (Mar 16, 2005)

Yes, that's correct.  I left 'root' but changed the pass to what I wanted it to be...then saved the file.

:m


----------



## michaelsanford (Mar 16, 2005)

Ok that's what I'm talking abuot--you're confounding phpMyAdmin, which is a web based INTERFACE for MySQL, and the ACTUAL MySQL SERVER.

In the terminal do this:
*ps ax | grep mysqld | grep -v grep*

Do you get a line that looks like this
352  ??  S      5:34.55 /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/m....blah blah

Or do you get nothing ?


----------



## midazolam (Mar 16, 2005)

Actually, Terminal flicks for a split second, then I get my default prompt... it doesn't show anything at all...

:m


----------



## michaelsanford (Mar 16, 2005)

Ok that means your mysql server isn't actually running. Also I'm concerned about your bash: error because it means that it can't find the mysql client program to communicate with the mysql server.

You ran the mysql.pkg installer and installed the startup item also ?

In the Terminal type
*ls /usr/local/mysql* you should get output like this:

homestar-runner:/usr/local/mysql root# ls /usr/local/mysql
COPYING                 bin                     include                 scripts                 tests
EXCEPTIONS-CLIENT       configure               lib                     share
INSTALL-BINARY          data                    man                     sql-bench
README                  docs                    mysql-test              support-files

If it says instead
*ls: /usr/local/mysql: No such file or directory*
Then either Mysql got installed in a funny place, or the install didn't work properly.

If the second one is the case, try reinstalling the .pkg.

Just remember, phpMyAdmin is not MySQL itself, it's just an interface. Think of it like the phones in your house. You can pick up any number of different telephones but they all ring the same number, right ? That's like phpMyAdmin. It's just one of the numerous ways you can communicate with MySQL, which would be the phone line in this analogy.

Editing config.inc.php has NO effect on MySQL's passwords.

Incidentally, if you select the http config method you don't need to put in a password because you'll be prompted for one when you hit the page with your web browser.


----------



## midazolam (Mar 16, 2005)

OK I *do* get the list of files, etc. which tells us that it IS installed...

This doesn't explain the other issues, however...

Thanks so much for all the help...

:m


----------



## michaelsanford (Mar 16, 2005)

I don't usually say this, but try rebooting, see if MySQL starts up that time,


----------



## midazolam (Mar 16, 2005)

I _did_ try rebooting earlier today, but will do so again now and see where I get...

:m


----------



## midazolam (Mar 16, 2005)

I rebooted (tried shutting off my external drive for kicks, too) and when i do a *ls /usr/local/mysql* the contents still display.  When I try *mysql -u root* I still get the "command not found" returned.

:m


----------



## michaelsanford (Mar 16, 2005)

Then mysql isn't in your $path. If you're using the tcsh shell then add the following line to the file .tcshrc in your home folder (make it if it doesn't exist, make sure it starts with a dot) I suggest using the *pico* editor in the terminal:
*setenv PATH "${PATH}:/usr/local/mysql/bin"*

The log out and open a new shell, try *mysql -u root* again.


----------



## midazolam (Mar 16, 2005)

currently I am using the default bash shell - as mentioned (albeit vaguely) in my first post...

Also, I didn't mention it but when I logged in to MyPHPAdmin (by resetting the config file to 'config') all that showed up was the error message from when I tried to log in when it was set to 'http'

Is my problem that I am trying to use the bash shell?  And if so, is there a way I can make the default shell tcsh?

:m


----------



## michaelsanford (Mar 16, 2005)

No bash is great actually it's the shell I use, but tcsh used to be the default shell (I think at least).

To add it to a bash $PATH add this to ~/.bashrc
*export PATH=$PATH:/usr/local/mysql/bin*


----------



## midazolam (Mar 16, 2005)

OK I just tried using a tcsh shell and when I try to do a *mysql -u root]* I still get the "Command not found" return.  I'm going to try the tcsh command you gave me to if that makes any difference

:m


----------



## michaelsanford (Mar 16, 2005)

Well...tcsh is the shell right, so if you use the tcsh command in a bash shell it won't do anything. Those two files set shell environment parameters...


----------



## midazolam (Mar 16, 2005)

michaelsanford said:
			
		

> No bash is great actually it's the shell I use, but tcsh used to be the default shell (I think at least).
> 
> To add it to a bash $PATH add this to ~/.bashrc
> *export PATH=$PATH:/usr/local/mysql/bin*



I created a .bashrc file in my home directory.  I then logged out and logged back in with a new shell - and still get the return "-bash: mysql: command not found"

*sigh*

hehe - I love computers.


----------



## midazolam (Mar 16, 2005)

Found something interesting:

in /usr/local there are *2* mysql dirs:

mysql and mysql-standard-4.1.10a-apple-darwin7.7.0-powerpc

Could this be the problem?  could it be trying to access the wrong dir?

HEre's what I see in each:

brians:/usr/local brian$ ls mysql
COPYING                 data                    scripts
EXCEPTIONS-CLIENT       docs                    share
INSTALL-BINARY          include                 sql-bench
README                  lib                     support-files
bin                     man                     tests
configure               mysql-test
brians:/usr/local brian$ ls mysql-standard-4.1.10a-apple-darwin7.7.0-powerpc
COPYING                 data                    scripts
EXCEPTIONS-CLIENT       docs                    share
INSTALL-BINARY          include                 sql-bench
README                  lib                     support-files
bin                     man                     tests
configure               mysql-test

:m


----------



## michaelsanford (Mar 16, 2005)

Go *ls -la* instead of just *ls* and you'll see that the one named mysql is really mysql@, it's a sumlink (alias) to mysql-standard-4.1.10a-apple-darwin7.7.0-powerpc


----------



## midazolam (Mar 16, 2005)

also of interest:

I read through the readMe again to see if there was anything I may have missed.  There's a note in there about creating an alias by entering the commands *alias mysql=/usr/local/mysql/bin/mysql* and *alias mysqladmin=/usr/local/mysql/bin/mysqladmin*

I entered those and then tried *mysql -u root*

and got _ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)_


----------



## midazolam (Mar 16, 2005)

I've been trying to find out (and there's nothing in the documentation that is with the package I downloaded) how to uninstall mySQL completely so that I can perform a clean install - was thinking this might be worth a shot.  The closest I've found was on Adobe's site - but it was for a really old version...

Could you point me in the right direction?

:m


----------



## midazolam (Mar 17, 2005)

Thought I would put this here for anyone else who wants to uninstall.  I did a search here and found this thread:

http://www.macosx.com/forums/showthread.php?t=31782&highlight=uninstall+mysql

Thanks again for all your help, Michael!


----------



## michaelsanford (Mar 17, 2005)

Ironic that I appear on that thread too...


----------



## midazolam (Mar 18, 2005)

OK I reinstalled the system (because of another problem I discovered).  I hoped this might help, and it did to a point.  I've reinstalled MySQL and PHP following all the instructions at Mark Liyanage's site, and I'm able to connect to MySQL via terminal without a problem, and the port is bound to 3306 - everything seems fine, but if I try to connect to it with cocoaMySQL it gives me this:

Connection Failed!

Unable to connect to host 127.0.0.1.
Be sure that the address is correct and that you have the necessary privileges.

I can telnet to localhost on 3306
I can telnet to 127.0.0.1 on 3306 and get the following:

telnet 127.0.0.1 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
>
4.1.10a-standardZ*`(ANGY,g|Y*`(CYt^X"

Any ideas anyone?


----------



## midazolam (Mar 28, 2005)

Just a little update - the issue with the machine was either processor or logic-board related.  In speaking with the tech who is repairing the machine, I learned that when the logic board is having troubles, sometimes files that are supposed to be invisible become visible, along with other problems.  In all likelihood, that's where the problems with MySQL were going on - sounds like it screws with the permissions, etc.

:m


----------

