View Full Version : starting MySQL
laram
06-02-2002, 11:52 AM
I recently downloaded MySQL 3.23.43 from the Marc Liyanage web site (http://www.entropy.ch/software/macosx/mysql/) and am unable to start MySQL by using the 'sudo safe_mysqld' command in the Terminal. All I get in reply is 'safe_mysqld: command not found'. I am able to get MySQL to start up, however, if I use a start-up script that I also downloaded from the Marc Liyanage site which executes when I start-up my computer - so I know it's able to work. I would much rather, though, be able to start and stop it whenever I want. Any advice from any of you out there? Keep in mind that I'm VERY new to the command line and MySQL so please phrase your advice in the most simple way possible.
Thanks.
JayBee
06-02-2002, 01:50 PM
Sounds like your mysql binaries directory hasn't been added to your path.
So what does that mean? Well, when you start a terminal session, the terminal sets up a series of directories (called your PATH) in which it looks for commands that you commonly execute. For example, when you type in "vm_stat" to print a summary of your current memory configuration, the terminal actually looks for "vm_stat" in all the directories in your path, and executes the first one it finds.
Technically, by typing in "vm_stat", you're really typing in "/usr/bin/vm_stat", but the terminal is just filling in the gaps because /usr/bin lies in your path, so "vm_stat" was found.
<edit>
meant to add - by typing in "echo $PATH" at the % prompt, you can view a list of all the directories in your current path.
</edit>
Now, to your mysql problem. MySQL generally installs a set of programs of its own in a separate directory. Usually, this directory is called "bin", and is a sub-directory of wherever your MySQL installation was put. On most systems, this lives in "/usr/local/mysql/bin".
To confirm this, type the following into your terminal at the % prompt:
% sudo find / -name safe_mysqld
This will ask you for your admin user password, then search your filesystem for the "safe_mysqld" program. It may take a wee while to run
If it doesn't find anything then you have a problem - let me know and we'll sort something out. However, if it does, it'll print out something like the following:
/usr/local/mysql/bin/safe_mysqld
In this case, all I have to do is type in "sudo /usr/local/mysql/bin/safe_mysqld &" (with any optional user arguments) to fire up the server manually.
That's a bit cumbersome though - ideally we want to put /usr/local/mysql/bin into our path. To do this, go to your home directory, and type "pico .tcshrc". This will open a file called .tcshrc into the Pico text editor.
Next, enter the following text (replacing /usr/local/mysql/bin with wherever your safe_mysqld was found):
set path=( $path /usr/local/mysql/bin )
Once you've done that (you may need to hit return at the end of the line, so that there's a blank line underneath this one), press <ctrl>+<x>, then <y>, then <enter>. Type "exit" at the command line, close the window if it doesn't close automatically, then open a new window and try typing "sudo safe_mysqld &". Problem should be fixed, as the terminal will now be looking in /usr/local/mysql/bin (or wherever you typed in) for your command, and will now be able to find it.
Just out of curiosity, what user are you running MySQL under? For security reasons, you should really set up MySQL to run under its own user - have a look at this page (http://developer.apple.com/internet/macosx/osdb.html) for further details. It's an excellent tutorial on a number of subjects (NetInfo, MySQL, compiling from source etc) in a single practical example. And it's an apple tutorial to boot! :)
mervTormel
06-02-2002, 02:51 PM
simple, eh? well, laram, if you swaller'd all of that, you learned about a hunred tousand tings. if you get 'caught up short' anywhere in there, just post back here and we'll wrangle up some more esoterica for you.
[edit: JayBee - excellent guide, kimosabe]
JayBee
06-02-2002, 03:44 PM
laram - Yeah, I should have said: As always in this place, if things come unstuck, get back to us. Someone (probably merv - very few people are fast enough to catch him!) will be able to help you out!
And cheers merv - "grasshopper" has much to learn. Brevity, for one thing... ;)
laram
06-02-2002, 04:49 PM
JayBee,
I did find 'safe_mysqld' where you said I should (/usr/local/mysql/bin/safe_mysqld), but typing in the command 'sudo /usr/local/mysql/bin/safe_mysqld &' did not start up MySQL. Maybe I'm missing the optional user arguments you mentioned. Any more advice?
mervTormel
06-02-2002, 05:40 PM
Originally posted by JayBee
...Brevity, for one thing...
naw, i could listen to your feckless meandering all day long :D
it's often very difficult to be brief when explaining the mechanisms of how this stuff works, as elements often thread back to a fundamental foundation that needs a tome of explaining.
it takes a bit of detective work and the socratic method of discovery to put all the chunks in a bag, but with some tenacity, you'll turn a corner and get smacked full in the face with Archimides' "Eureka!" just don't forget to put your clothes on.
as for the path to /usr/local/blah , you might ( read do ) want /usr/local/blah to come at the front of the path...
set path=( /usr/local/mysql/bin $path )
that way, the binaries you install in /usr/local/blah will override the vanilla installed binaries in later path dirs.
mervTormel
06-02-2002, 05:44 PM
Originally posted by laram
I did find 'safe_mysqld' where you said I should (/usr/local/mysql/bin/safe_mysqld), but typing in the command 'sudo /usr/local/mysql/bin/safe_mysqld &' did not start up MySQL. Maybe I'm missing the optional user arguments you mentioned. Any more advice?
the incantation
sudo command &
don't work too very good.
it's better to use sudo -b without the background "&" , but then you loose job control
try:
% sudo -b /usr/local/mysql/bin/safe_mysqld
then look for the job in:
% ps al
laram
06-02-2002, 05:55 PM
Tried ' sudo -b /usr/local/mysql/bin/safe_mysqld' and got this reply...
'The file /usr/local/mysql/libexec/mysqld doesn't exist or is not executable
Please do a cd to the mysql installation directory and restart
this script from there as follows:
./bin/safe_mysqld.'
This may seem like a do-able set of instructions to many you but could some one please clarify it to me?
Thanks
JayBee
06-02-2002, 10:50 PM
Originally posted by mervTormel
naw, i could listen to your feckless meandering all day long :D
Yeah, but you know enough to know what I mean to say :p.
As for your instructions, laram, here's a quick breakdown of the terminal commands. I've put some brief explanations under each one - brace yourselves for some more meandering ;)
% cd /usr/local/mysql
// _c_hange _d_irectory to your mysql directory.
% sudo -b ./bin/safe_mysqld
// the sudo -b bit we already know about.
// the "." at the start of the command here tells the shell to start with
// the current directory (in this case /usr/local/mysql), and then proceed
// into the following directories.
// In this case, "./bin/safe_mysqld" means "/usr/local/mysql/bin/safe_mysqld"
Now, as to WHY this behaviour is needed, I'm not sure. Your error message hints that /usr/local/mysql/libexec/mysqld (which is the program that safe_mysqld actually runs) may not be executable. Try the following code, and come back with the result:
% sudo ls -l /usr/local/mysql/libexec/ | grep mysqld
// ls -l will list the contents of the directory named
// in this case, /usr/local/mysql/libexec
// this list is then "piped" to the grep command
// (_g_et _r_egular _e_x_p_ression), which filters the directory
// list so that we only get the file we're interested in - in this case
// only the line containing "mysqld" will be returned. It'll look something like:
-rwxr-xr-x 1 root mysql 1577368 May 8 18:58 mysqld
// the 'x's near the start of the line mean that my mysqld is
// e_x_excutable.
// Let's have a look at yours!
laram
06-02-2002, 11:12 PM
My reply looked like this...
-rw-r--r-- 1 root wheel 0 May 11 16:13 safe_mysqld
mervTormel
06-03-2002, 12:12 AM
i would have to say that you have not successfully installed mysql. your only recourse at this juncture is to try to install it again.
and go ahead and copy/paste a little more detail directly from the shell in your replies here rather than just the output. we'd like to see how you get your results. e.g., i don't have mysql installed at that path, so i'd see this...
% ls -l /usr/local/mysql/libexec/ | grep mysqld
ls: /usr/local/mysql/libexec/: No such file or directory
my point is, copy/paste your command and the results back here. mind you, if your results are twenty pages long, you'll just want to summarize with the more interesting pieces. right, right?
laram
06-03-2002, 07:26 AM
Re-install? Okay, I'll give it a try either later today or tomorrow. Please stay tuned.
JayBee
06-03-2002, 07:56 AM
laram - if you're going to give the re-install a go, try following the tutorial I pointed out over at Apple Developer (http://developer.apple.com/internet/macosx/osdb.html). It's really hand-holdy, and explains a heck of a lot about what you're doing.
The only thing to watch out for is the bit where it mentions putting the mysql socket in a custom location. You don't have to worry about what this means, but I've had issues with PHP using this. PHP expects to find the socket at a certain location by default, and if it's not there, it throws a fit.
My advice would be to follow the instructions, but where you are told to type the following:
./configure --prefix=/usr/local/mysql --with-unix-socket-path=/usr/local/mysql/run/mysql_socket --with-mysql-user.... etc etc
Leave the option starting "--with-unix-socket-path" out. ie
./configure --prefix=/usr/local/mysql --with-mysql-user=mysql --with-comment.... etc etc
The only disadvantage with installing from source is that you won't have MySQL startup with the system by default. However, there's at least one tip on the main site about how to do this.
Best of luck! :)
laram
06-03-2002, 09:01 AM
I re-installed and I got MySQL to start by inputting the terminal command...
'sudo safe_mysqld'
Yay! Thank you Merv and Jaybee.
Jaybee, I got your instructions on how to re-install after I already did the deed. What I did instead was to go back to the Marc Liyanage web site (http://www.entropy.ch/software/macosx/mysql/) and used an un-install script that he provided and then installed again using his instructions. I guess the first time I tried it I did something wrong.
My next question; now that I can turn it on, how do I turn it off?
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.