The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Can't connect to MySQL (http://hintsforums.macworld.com/showthread.php?t=9044)

td6 01-31-2003 02:10 PM

Can't connect to MySQL
 
I've installed MySQL but can't connect to it. I've tried "mysql -u root -p" but I get "mysql: command not found" I know MySQL is running, because I have the MySQL preferance pane and it shows it's running. Appreciate any help...

yellow 01-31-2003 02:22 PM

My first guess is that it says that becuase where the binary for mysql lives isn't in your path. Where it resides will Depending on how you installed it (fink?).

td6 01-31-2003 02:33 PM

No, I didn't use Fink. I used Complete MySQL 3.23.54a. but that was after I installed it from the notes on http://www.entropy.ch/software/macosx/mysql/#install. (i upgraded from 3.23.51) --my reasoning--- i wasn't sure if I installed it correctly myself being a newbie...

yellow 01-31-2003 02:52 PM

editing your default path
 
You know, I had a lot of troubles with this build/install of mysql myself and finally gave up since I had more pressing matters at hand to work on.
Make sure you have /usr/local/bin in your path. To check use the command:

set | grep path

to list your default paths. If not, you can then copy /etc/.csh.login to your home dir, rename it .login, change ownership (chown (sudo chown yourusername ~/.login) it to your username, and change the path in there to reflect the addition of /usr/local/bin*. From then on when you open a new Terminal window (or xterm) your default path will be correct. It's best not to add this to the /etc/csh.login file because it's universal and other users on your system don't necessarily need it.

Hope this helps!

Jacques

[FINK USERS PLEASE NOTE: This WILL break your fink path (the source /sw/bin/init.csh) from your .tcshrc. To fix this, simply add the line from your .tcshrc into your .login file after the setenv line. The next time you open a window, everything will be just ducky.]

td6 01-31-2003 03:09 PM

if I put in set | grep path, what am i supposed to get?

yellow 01-31-2003 03:17 PM

set is a command used to list your current settings. | is called a "pipe" and it means that you want to send the output from your first command (set) thru a second command (grep path). grep is a command that matches input against an argument ("path") and outputs the info to a specified place (by default the same window you're entering the command into). So when you enter this you should see something like:

path (/sw/bin /sw/sbin /bin /sbin /usr/bin /usr/sbin /usr/X11R6/bin)

Try just using set by itself as a command to see what you get and this will make a little more sense. We're just stripping out the stuff we don't want and only going for the "path" info.

td6 01-31-2003 03:33 PM

thanks for the info, but... I probably messed something up in the install. Is there any way to delete MySQL? Then reinstall it properly.

thanks...

yellow 01-31-2003 03:36 PM

ok, but when you get "mysql: command not found" it means it's either not installed or it's not in your path. I suspect the latter here. Why don't you try:

/usr/local/bin/mysql -u root -p

This is the default directory for the mysql binary, so if this works, or doesn't return "mysql: command not found" then you know your earlier problem was indeed not having the path.

yellow 01-31-2003 03:38 PM

On another note, mysql is slightly complicated for a UNIX newbie to be fiddling with ;)

td6 01-31-2003 03:43 PM

yeah, i know... I'm just trying to get my machine set-up so i can test websites using databases...

I'm in.... dig it!!

thanks for all the Help!!

yellow 01-31-2003 03:53 PM

Cool, glad it worked.
To save yourself time you should consider trying to follow the directions above to add /usr/local/bin to your default path. A lot of downloaded and compiled/installed UNIX binaries end up in /user/local/bin/. If you need more help, just post here and I'll help you out.

td6 01-31-2003 04:21 PM

Edit the Path
 
ok, lets do this step by step...

Quote:

to list your default paths. If not, you can then copy /etc/.csh.login to your home dir, rename it .login, change ownership (chown (sudo chown yourusername ~/.login) it to your username, and change the path in there to reflect the addition of /usr/local/bin*. From then on when you open a new Terminal window (or xterm) your default path will be correct. It's best not to add this to the /etc/csh.login file because it's universal and other users on your system don't necessarily need it.
I understand what we're doing, just not how to do it!

yellow 01-31-2003 05:13 PM

Changing default paths - 101
 
OK here are the basic commands and terminology we'll use here:
cp (UNIX command for copy)
sudo (UNIX comamnd to 'do as if I was root')
~ (UNIX shortcut for my home directory [called tilda])
chown (UNIX command for changing user and group ownership of files and directories)
pico (UNIX text editor, very easy to use)

First off, open a Terminal window and type:

sudo cp /etc/.csh.login ~/.login

This will copy the file .csh.login located in /etc to your home directory (~) and change it's name to ".login". You will be prompted for your user password (you must be an admin on this computer or in /etc/sudoers) because of sudo. Enter yur password and hit return. Next type:

sudo chown yourusername ~/.login

This will change the owner of .login from root to you, provided you put your user name in place of yourusername. You will not be prompted for a password because sudo holds your 'passkey' for 5 minutes. Now you own .login. Next type:

pico ~/.login

You will now be editing your .login file to add the missing path. Now you will see something like this in the editor window:

# System-wide .login file for csh(1).

setenv PATH "/bin:/sbin:/usr/bin:/usr/sbin"


Pico does not support a mouse, so use your arrow keys to move the cursor to the end of the last line and place it over the double-quote ("). Now type:
:/usr/local/bin
Now that line should look like this:
setenv PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
Let's save and quit pico now. At the bottom of the window you see commands like ^W and ^G, ^ is the UNIX indicator for the control key, so to exit the editor, hit control-x (^X). Answer y (yes) to "Save modified buffer?", hit return answer yes to "Name File to write: .login", and it's edited.

Now when you open a new Terminal window, your path will include by default /usr/local/bin as well.

Learning more about the basics of UNIX is in your best interest if you're going to be playing about in it, especially with mysql. A very good resource for the UNIX newbie and Mac OS X is "Learning UNIX For Mac OS X" [ http://store.apple.com/1-800-MY-APPL...27.8.3.10.13.0 ] available at many fine bookstores :D

td6 02-02-2003 12:23 PM

ok... the g4 at work is running fine, but the g3 at home is giving me this error message when I try to connect to mysql:


ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)

any ideas?

yellow 02-02-2003 03:45 PM

Hmm got a firewall that's blocking localhost (127.0.0.1)?

td6 02-02-2003 09:00 PM

firewall---no. according to the system prefs, it's turned off. this machine is hooked-up only to a dial-up modem...

yellow 02-03-2003 09:23 AM

I am unfamiliar with this error. It's possible that this one is a munged install. However, I don't know how mysql behaves on a computer with no perminant network connection. I imagine it would work just fine since all the "networking" calls it makes to itself are within it's own network stack. I've never seen this error before though.

stetner 02-03-2003 09:23 PM

The socket is a UNIX socket in /tmp, so it should not have to do with network. From the entropy web site above:
Code:

type "sudo ./bin/safe_mysqld --user=mysql &"
Did it start the daemon? Try a:
Code:

% ps -aux | grep sql
root    3544  0.0  0.1    1828    592 std  S    12:20PM  0:00.91 sh /sw/bin/safe_mysqld
mysql    3555  0.0  0.1    12868  1172 std  S    12:20PM  0:00.05 /sw/sbin/mysqld
stetner  3568  0.0  0.0    1116      4 std  R+  12:21PM  0:00.00 grep sql

and see if the daemon (mysqld) is running....

Cheers,

td6 02-04-2003 12:44 PM

ok, after typing in:

sudo ./bin/safe_mysqld --user=mysql &

i'm asked for the password. when i put in the password, i get:

command not found.

I checked for "mysqld" in the app process viewer and got nothing. So, the daemon isn't running...

stetner 02-04-2003 05:04 PM

Ok, so the daemon not running is the real problem.

So going back to the entropy instructions, when you ran the command safe_mysqld were you in the correct directory?
Code:

cd /usr/local/mysql"               
...
...
type "sudo ./bin/safe_mysqld --user=mysql &"               
Use it with "/usr/local/bin/mysql test"

Show us what

td6 02-04-2003 08:04 PM

Yeah, you were right. I went back to the website and started here:

Quote:

4. type "cd /usr/local/mysql"
5. type "sudo ./scripts/mysql_install_db", enter administrator password when asked
6. type "sudo chown -R mysql /usr/local/mysql/*"
7. type "sudo ./bin/safe_mysqld --user=mysql &"
8. Use it with "mysql test"
thanks! It hit me as soon as I saw what you wrote...

macubergeek 02-18-2003 01:00 PM

EASY STEPs
 
1. check to see if you installed it
do which mysql, which mysqld and see where they are located

2. check to see if mysql is actually running. You can't connect to mysql if it is not running

ps aux | grep mysqld

3. if it is running THEN check to see if it is in your path....
do: echo $PATH
this will tell you what your path is, then you check to see if where mysqld is installed is in your exisiting path.

good luck!

psycorpse 03-01-2003 10:36 AM

You can also try it with out the &. That is what I had to do.
sudo ./bin/safe_mysqld --user=mysql

The only problem that I have with that is I have to close the terminal window and open another one. However that isnt a big deal to me.

macubergeek 03-01-2003 11:07 AM

Complete mysql
 
Just installed this. It puts a control panel in System prefs with which you can start/stop mysql and reset the mysql database root password.

http://www.versiontracker.com/morein...d=17951&db=mac

intrntmn 03-01-2003 12:27 PM

mysql startup
 
Quote:

Originally posted by psycorpse
You can also try it with out the &. That is what I had to do.
sudo ./bin/safe_mysqld --user=mysql

The only problem that I have with that is I have to close the terminal window and open another one. However that isnt a big deal to me.
At the end of the above command, add an ampersand (&) ... this will perform the command "in the background" and return you to the command line.

Code:

sudo ./bin/safe_mysqld --user=mysql &
Jack


All times are GMT -5. The time now is 10:25 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.