running MySQL

Still having some issues with this. Need to clarify some things. I recently installed mysql standard version 5.0.27 on 10.4.6 and also installed MySQLStartupItem as well.

- Now the docs said with the MySQLStartupItem the MySQL will start automatically during system startup. Does this mean the MySQL server will be activated automatically?

- There are two ways to start the MySQL server. With sudo ./bin/mysqld_safe or sudo /Library/StartupItem/MySQLCOM/MySQLCOM start. When I use the first I get this -- ./bin/mysqld_safe: line 1: ./bin/my printdefaults: cannot execute binary file
./bin/mysqld_safe: line 1: ./bin/my printdefaults: cannot execute binary file
Starting mysqld daemon with databases from /usr/local/mysql/data
STOPPING server from pid file /usr/local/mysql/data/robert-bennetts-imac.local.pid
061203 00:02:43 mysqld ended
When I use sudo /Library/StartupItem/MySQLCOM/MySQLCOM start i get -- Starting MySQL database server but I'm not convinced it's working because none of the commands that the docs say should work actually work. Like if I use the command mysql to get into the database i get this -- -bash: mysql: command not found

Help much appreciated. This has been a wall I've been unable to break through.

Mac OS X (10.4.6)

Posted on Dec 3, 2006 12:23 AM

Reply
10 replies

Dec 3, 2006 8:46 AM in response to Houdini

Dear bobster37,

To see if mysql is running you can do several things.

1. Go to System Preferences->MySQL and if it says, "The MySQL Server Instance is running", then it is.

2. Open the program Activity Monitor, which is in the Applications/Utilities folder. Type in "mysql" in the search bar where "All Processes" choice is visible. If you see the "mysqld" under "Process Name", then it is running.

3. In the Terminal Program located in Applications/Utilities type "top" and hit enter. You should see a list of current processes. By making the Terminal window very long you should be able to see most of the processes. One of these should be "mysqld". Type "q" to quit.

Once you confirm that the mysql demon is running, you now need to make sure that the path you type for the mysql command is understood by your shell. You can only type "mysql" if the shell knows which directory to look in to find this command.

My "mysql" command is in the directory: /Library/MySQL/bin. If yours is too, then type "/Library/MySQL/bin/mysql" and mysql should run just fine. If this is the case, then you can read up on adding the "/Library/MySQL/bin" directory to the list of directories that your shell looks in to find commands. This list of directories is in the PATH variable. You can find out what this is by typing "echo $PATH" and then hitting enter. This will tell you where the shell will look for commands that you type.

If you need help adding a directory to your PATH variable, post back and I will help you with that.

I hope this was helpful.

Dec 3, 2006 4:33 AM in response to Houdini

If you are not familiar with the shell command line, then you can use various GUI tools.

First of all, did you notice a file "MySQL.prefPane" is included in the mysql dmg you used for installation? Copy the prefPane into ~/Library/PreferencePanes/. Then you can control mysqld (the MySQL server) from System Preferences; you can start/stop the server, and also see whether the server is running or not.

As the MySQL client, you may use MySQL GUI tools or CocoaMySQL (see Charles Minow's post in your another thread).

If you want to use mysql command (MySQL client) from the shell, then you need minimum amount of knowledge of the shell you are using. If you have set PATH in your .bashrc but it didn't work, you need to set it in .bash_profile (I assume you know what the PATH means). As the last resort, you can start mysql command by typing '/usr/local/mysql/bin/mysql' into your shell command line.

Dec 3, 2006 8:59 AM in response to Houdini

Hi--

- Now the docs said with the MySQLStartupItem the
MySQL will start automatically during system startup.
Does this mean the MySQL server will be activated
automatically?


Yes, once you install that, it should start when you reboot your computer.

When
I use the first I get this -- ./bin/mysqld_safe:
line 1: ./bin/my printdefaults: cannot execute
binary file
/bin/mysqld_safe: line 1: ./bin/my printdefaults:
cannot execute binary file
Starting mysqld daemon with databases from
/usr/local/mysql/data
STOPPING server from pid file
/usr/local/mysql/data/robert-bennetts-imac.local.pid
061203 00:02:43 mysqld ended


Well, you'd have to post exactly what command you're using. The MySQL daemon is started by mysqld_safe, but if you look, that's just a shell script that does a bunch of things to set it all up, eventually resulting in the MySQL daemon starting up. One thing to keep in mind is that the daemon has to run as the mysql user, which is already set up on your computer, but you have to tell it to:

<pre class="command">./bin/mysqld_safe --user-mysql &</pre>

Also, when I used the mysqld_safe to start the server, I had problems starting the server because of having to give my password. So I would start it with the following series of commands:

<pre class="command">cd /usr/local/mysql
sudo su
./bin/mysqld_safe --user-mysql &
exit</pre>Once I'd supplied my password in the second step, I had root privileges, so I didn't have the problem with the password any more. Note that after the third step, you'll get some status text printed on the screen. If it's unsuccessful starting, you should get the reason why. If it starts successfully, you'll eventually get back to a shell prompt. One of the last things it prints will be a number in brackets: [nnnnn], which is the process id of MySQL.

You should be able to see mysqld in the Activity Monitor if you set it to look at "All Processes." Otherwise, it's also possible to check for it in the Terminal:

<pre class="command">ps ax | grep -v grep | grep mysql</pre>You should see two lines similar to this (they're truncated, by the way, to the width of the Terminal window):

<pre class="command">10367 p1- S 0:00.04 /bin/sh ./bin/mysqld_safe --datadir=/usr/local/mysql/
10387 p1- S 3:21.05 /usr/local/mysql/bin/mysqld --defaults-extra-file=/us</pre>

When I use sudo
/Library/StartupItem/MySQLCOM/MySQLCOM start i get --
Starting MySQL database server but I'm not convinced
it's working because none of the commands that the
docs say should work actually work.


If you're using the startup item, it should print out error messages if it can't start the server. As Jun says in his post, you need to add /usr/local/mysql/bin to your shell $PATH.

Help much appreciated. This has been a wall I've
been unable to break through.


Like you, I had trouble with all this at first. I used the MySQL Visual QuickStart Guide by Larry Ullman to get going. I found it to be very helpful, especially at the early stages of learning about MySQL. I still refer to it periodically, so it's a handy reference to have.

charlie

Dec 4, 2006 1:29 AM in response to mahongue

Thank you for that information. Unfortunately there's something missing in my setup. Neither commands are working. sudo ./bin/mysqld_safe --user=mysql & nor sudo /Library/StartupItem/MySQLCOM/MySQLCOM start. I've checked with top and theirs no mysqld running and in Activity Monitor there's no mysqld under process name. My mysql command is in /usr/local/mysql/bin. But of course this is irrelevent if the mysql server isn't running. This is weird that my MySQL isn't working. I received no error when installing the MySQL software. It's also weird that after installing the MySQL.prefpane in Library/PreferencePanes when I double click it to load it gives me an error -- Preferences Error Could not load MySQL. And also in System Preferences under other there's a icon to load MySQL and when I double click it I get the same error -- Preferences Error Could not load MySQL. There's definitely something not jiving in my setup. Anymore help would be great. Thank you.

Dec 14, 2006 9:28 AM in response to Houdini

I'm having trouble with MySQL through the command line too. I know I've got it installed, and the prefs pane shows that it's running, I've also used the MySQL Administrator utility to set up the root password, and create a user for myself. However, when I launch terminal and type mysql (or the many other suggestions given on this forum) I just get responses like 'command not found'. I have the book by Ben Forta 'MySQL crash course' and it says to go to the OS command line (which I assume is terminal) and type mysql. Does anyone have the answer?

Dec 14, 2006 12:13 PM in response to bilbo_baggins

Just to clarify my question: I want to know how to access the mysql command-line utility that is supposedly included in the standard installation. I have mysql running locally (I know both from the prefs pane, plus when I type sudo /Library/StartupItems/MySQLCOM/MySQLCOM start I get the response 'Starting MySQL database server'. However when I type mysql I just get 'command not found'. According to my book I should get the response: Welcome to the mysql monitor... etc. and then a mysql> prompt.

Dec 14, 2006 12:27 PM in response to bilbo_baggins

Hi--

However when I type mysql I just get 'command not
found'. According to my book I should get the
response: Welcome to the mysql monitor... etc. and
then a mysql> prompt.


That's because the directory where the mysql binary lives isn't in your $PATH. You can either use the full path:

<pre class="command">/usr/local/mysql/bin/mysql</pre>Or you can add it to your path. To add it to your path, assuming you're using a bash shell (the default in a new Tiger install), you need to add this line to your .bash_profile, which is in your home directory (it may not exist if you haven't already created it, or if it does, it's invisible):

<pre class="command">export PATH=$PATH:/usr/local/mysql/bin</pre>To create the file if it doesn't exits, you can use nano, a simple text editor:

<pre class="command">nano ~/.bash_profile</pre>Changes to that file don't show up right away unless you run bash again, or close the Terminal window and open up a new one.

charlie

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

running MySQL

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.