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

midazolam

Registered
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
 
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'
 
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
 
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 ?
 
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 ?
 
Actually, Terminal flicks for a split second, then I get my default prompt... it doesn't show anything at all...

:m
 
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.
 
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
 
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
 
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.
 
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
 
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
 
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
 
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...
 
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.
 
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
 
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
 
Back
Top