MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Mac OS X MySQL Install

with 102 comments

Installing MySQL 5.5.9 (updated for MySQL 5.5.16 and 5.5.18) on Mac OS X was on my list but it finally made the top. I needed to write instructions for a class that I teach because asking students who own a Mac to install VMWare and Windows before MySQL seems an unnecessary burden. Especially when you can install it directly on Mac OS X.

Mac OS X Mountain Lion (10.8.*) need to install XCode and Command Line Tools before installing MySQL. You can refer to this XCode installation and configuration post for those steps.

You can download MySQL for the Mac OS X. I downloaded the Mac OS X, Version 10.6 (x86, 64-bit) version for this installation. There were a couple shell syntax tricks beyond the instructions and then you need to configure database. That’s required because the database is installed with an unsecured anonymous and root account. After the step-by-step installation instructions, you’ll find the configuration steps to enable you to access the MySQL Monitor from a terminal session. It also configures your $PATH environment to enable you to start and stop the MySQL Daemon.

  1. After the download completes, open the file folder in the download directory.

  1. The open file folder and it will look like the following. Launch the mysql-5.5.9-osx 10.6-x86_64.pkg file, which installs the product.

  1. After launching the executable, you are now on the first page of the Install MySQL 5.5.9 installation application. Click the Continue button.

  1. This page contains the instructions, you can pause to read them or continue with these instructions. Click the Continue button to proceed.

  1. This page contains the General Public License (GPL). You agree or stop the installation. Click the Continue button to proceed.

  1. The following overlay dialog contains your agreement. Click the Agree button to proceed.

  1. There are fewer options in this installation than the Windows installation. While you can change the installation location, the software installs by default in the /usr/local/mysql directory. The installation requires that you have a mysql user account on the operating system, and you don’t need to do anything because one exists as part of the default Mac OS X installation. Click the Install button to proceed.

  1. This dialog requires the system administrator’s password. Enter the valid password and click the OK button to proceed.

  1. Depending on the system, this could take more than a minute. All you can do it wait.

  1. This page tells you that you’ve completed the installation. Click the Close button to proceed.

  1. This step requires that you return to the download folder, shown in Step #2 above. Launch the MySQLStartupItem.pkg and you’ll see the following MySQL Startup Item Installer dialog. Click the Continue button to proceed.

  1. This page contains the instructions for the MySQL Startup software, you can pause to read them or continue with these instructions. Click the Continue button to proceed.

  1. This page asks if you want to change the directory. I’d recommend you leave it as the default because it requires the System Administrator’s password to start and stop the database. It should also start for you every time you boot the machine. Click the Continue button to proceed.

  1. Like Step #8, this dialog requires the system administrator’s password. Enter the valid password and click the OK button to proceed.

  1. You could see a progress dialog box but generally it happens so fast you should land at the Installation was Successful dialog. Click the Close button to proceed.

  1. This step requires that you return to the download folder, shown in Step #2 above. Launch the MySQL.prefPane and you’ll see the following MySQL Preferences dialog. Click the Install button to proceed.

  1. Like Step #8 and #14, this dialog requires the system administrator’s password. Enter the valid password and click the OK button to proceed.

  1. Don’t click in the automatic start button unless you’re sure. Otherwise, there’s a lot of cleanup to be able to return to this point and start or stop the server as required. This is the last screen, you should click the Start MySQL Server button to start MySQL. While installing MySQL 5.5.18 I discovered that the service menu is no longer installed in the Preferences, and you must start it manually.

You can start and stop the service by opening your System Preferences, where you’ll find them in the bottom Other row. If the intent was to have it start automatically, sometimes the permissions are incorrect. You’ll get the following error in MySQL 5.5.9 but not in MySQL 5.5.16 because the MySQL DMG file is fixed. You can skip the instructions until you get to Configure User’s Shell Environment below:

"/Library/StartupItems/MySQLCOM" has not been started because it does not have the proper security settings.

You can fix this by changing the permissions manually in a Terminal Session. Launch a Terminal Session from your Utilities folder inside your Applications folder.

Change directory to the /Library/StartupItems/MySQLCOM directory. Then, list the files. These commands should do the trick for you:

cd /Library/StartupItems/MySQLCOM
ls -al

If you see these permissions, you have problem because the group for startup files should be wheel not staff:

drwxr-xr-x  4 root  staff   136 Jan 20 13:46 .
drwxr-xr-x  4 root  wheel   136 Feb  9 21:11 ..
-rwxr-xr-x  1 root  staff  1300 Jan 20 13:46 MySQLCOM
-rw-r--r--  1 root  staff   469 Jan 20 13:46 StartupParameters.plist

You can change the files with this command:

sudo chown root:wheel *

However, now you need to step up the directory tree one level to /Library/StartupItems, and change the ownership of:

drwxr-xr-x   4 root  staff   136 Jan 20 13:46 MySQLCOM

There are two commands to do this. The first changes directory by moving to the parent directory in the hierarchy (the parent directory is represented by two dots). The second changes the group ownership of the MySQLCOM directory.

cd ..
sudo chown root:wheel MySQLCOM

Now you need to configure your shell environment and harden the database. Hardening means securing accounts with passwords. They’re covered in the next two sections.

Configure User’s Shell Environment

Assuming you accepted the defaults, you should be able to copy the required instructions directly into a .bash_login file if one exists. Unless you’ve created one before there won’t be a file. Mac OS X doesn’t automatically create the file. If you don’t have the file, you can create one with the following syntax:

touch .bash_login

You can open the file with the vi editor or a text editor of your choice. MySQL 5.5.9 installed in /usr/local/mysql, which has changed to /usr/local/mysql-version as noted below. You can copy the following contents into the file for MySQL 5.5.16 but will need to change the file for earlier or later releases (added sudo per Don McArthur’s comment):

# Set the MySQL Home environment variable to point to the root directory of the MySQL installation.
export set MYSQL_HOME=/usr/local/mysql-5.5.16-osx10.6-x86_64
 
# Add the /bin directory from the MYSQL_HOME location into your $PATH environment variable.
export set PATH=$PATH:$MYSQL_HOME/bin
 
# Create aliases that make it easier for you to manually start and stop the MySQL Daemon.
alias mysqlstart="sudo /Library/StartupItems/MySQLCOM start"
alias mysqlstop="sudo /Library/StartupItems/MySQLCOM stop"

Changes between MySQL 5.5.16 and 5.5.18 introduce a new directory structure, you need to use the following in the .bash_login file (added sudo and status per Don McArthur’s comments):

# Set the MySQL Home environment variable to point to the root directory of the MySQL installation.
export set MYSQL_HOME=/usr/local/mysql-5.5.18-osx10.6-x86_64
 
# Add the /bin directory from the MYSQL_HOME location into your $PATH environment variable.
export set PATH=$PATH:$MYSQL_HOME/bin
 
# Create aliases that make it easier for you to manually start and stop the MySQL Daemon.
alias mysqlstart="sudo /Library/StartupItems/MySQLCOM/MySQLCOM start"
alias mysqlstop="sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop"
alias mysqlstatus="ps aux | grep mysql | grep -v grep"

As pointed out by Shashank’s comment, you should now use the following aliases:

alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'

You need to save the file and close and restart a new Terminal session to place these environment variables in scope. You could also run the following to put them in scope without closing and opening the terminal:

. ./.bash_login

The preceding command sources the environment file into active memory. This should configure your environment. After restarting the shell, you should be able to run this command to confirm the new environment:

which -a mysql

It should return:

/usr/local/mysql-5.5.16-osx10.6-x86_64/bin/mysql

Secure the Database

This is presently necessary because of the different file structure in a Mac OS X MySQL install, which disables the mysql_secure_installation file from running successfully. You can manually edit the file or follow these steps.

You need to connect to the database as the privileged super user, root user. This is simple because the installation doesn’t set any passwords. You open another Terminal session to make these changes or you could install MyPHPAdmin or MySQL Workbench. The tools work as well in fixing the majority of issues.

mysql -uroot

Once connected to the database as the root user, you can confirm that passwords aren’t set and an insecure anonymous user account has been previously configured. You do that by connecting to the mysql database, which is the database catalog for MySQL. You do that by running the following command:

USE mysql;

You can query the result set with the following query:

SELECT USER, password, host FROM USER\G

You should see the following output plus the user’s name preceding the MacPro (or iMac.local) host name value:

*************************** 1. row ***************************
    user: root
password: 
    host: localhost
*************************** 2. row ***************************
    user: root
password: 
    host: MacPro.local
*************************** 3. row ***************************
    user: root
password: 
    host: 127.0.0.1
*************************** 4. row ***************************
    user: root
password: 
    host: ::1
*************************** 5. row ***************************
    user: 
password: 
    host: localhost
*************************** 6. row ***************************
    user: 
password: 
    host: MacPro.local

You now need to change the password for the root user. I would suggest that you do this with the SQL command rather than a direct update against the data dictionary tables. The syntax to fix the root user account require you enter the user name, an @ symbol, and complete host values, like:

SET PASSWORD FOR 'root'@'localhost' = password('cangetin');
SET PASSWORD FOR 'root'@'MacPro.local' = password('cangetin');
SET PASSWORD FOR 'root'@'127.0.0.1' = password('cangetin');
SET PASSWORD FOR 'root'@'::1' = password('cangetin');

You should be able to drop both anonymous user rows with the following syntax, but I did encounter a problem. Assuming you may likewise encounter the problem, the fix follows the first commands you should try:

DROP USER ''@'localhost';
DROP USER ''@'MacPro.local';

If either of the anonymous accounts remain in the USER table, you can manually drop them from the database catalog. This syntax will get rid of them:

DELETE FROM USER WHERE LENGTH(USER) = 0;

You’ve completed the configuration and can now type quit; to exit the MySQL Monitor. To reconnect, you’ll now need a password, like this:

mysql -uroot -pcangetin

Also, don’t forget to use a real password. The one shown here is trivial, which means easy to hack. Use something that others might not guess.

Configure my.cnf file

You can copy one of the sample configuration files as a starting point (as provided by Don McArthur’s comment):

sudo cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf

Starting and Stopping the Database

You can manually start the database server with the following command, which you defined as aliases in your .bash_login shell script:

mysqlstart

Stopping it is also straightforward, you do this:

mysqlstop

You can check it’s status with this command:

mysqlstatus

Written by maclochlainn

February 10th, 2011 at 2:57 am

Posted in Mac,Mac OS X,MAMP,MySQL

102 Responses to 'Mac OS X MySQL Install'

Subscribe to comments with RSS or TrackBack to 'Mac OS X MySQL Install'.

  1. [...] This post was mentioned on Twitter by mclaughj rss and OraNA.info, Yosuke KATSUKI [...]

  2. Wonderful instructions. Very detailed.

    I also like to install mysql using homebrew. You can get homebrew from here:

    https://github.com/mxcl/homebrew

    Then from the terminal, just type:
    brew install mysql

    When it is finished, it gives you a couple of instructions for initializing your database, setting it up to run on startup if you want, and startup and shutdown via terminal commands.

    (Note: this method requires that you have XCode installed because it compiles mysql from source)

    Hope that helps some.

    Mike Farmer

    10 Feb 11 at 12:39 pm

  3. Hi,

    I had earlier installed mysql-5.1.50-osx10.6-x86_64.dmg and then uninstalled it using the below belo command (found in stackoverflow)

    $ sudo rm /usr/local/mysql
    Password:
    $ sudo rm -rf /usr/local/mysql*
    $ sudo rm -rf /Library/StartupItems/MySQLCOM
    $ sudo rm -rf /Library/PreferencePanes/My*
    $ rm -rf ~/Library/PreferencePanes/My*
    $ sudo rm -rf /Library/Receipts/mysql*
    $ sudo rm -rf /Library/Receipts/MySQL*
    $ sudo vi /etc/hostconfig
    $ sudo rm -rf /var/db/receipts/com.mysql.mysql*
    $ cd /Library/Receipts/

    Then I have tried to reinstall from mysql-5.5.9-osx10.6-x86_64.dmg.

    However I am getting the below error:

    The installation failed The installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.

    Sarbbottam Bandyopadhyay

    21 Feb 11 at 10:42 am

  4. Everything works fine until I get to the step where I enter mysql -uroot and my computer returns this error:

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

    Also in the mysql startup window it lists the following under the startup button:

    Warning: The /var/lib/mysql directory is not owned by the 'mysql' or '_mysql' user.

    I’m new to navigating Unix and don’t know what to do next. Do you have any suggestions for how I handle the ownership?

    Katie

    23 Feb 11 at 11:55 am

  5. It appears you may need to add the password (the generic password that I use is cangetin), like

    mysql -uroot -pcangetin

    maclochlainn

    23 Feb 11 at 12:23 pm

  6. Nope. no change.

    Katie

    23 Feb 11 at 2:30 pm

  7. Katie, That was a quick thought from iPad earlier today, but looking at the message you posted, it appears you’ve opted for a different installation plan. The expected location for MySQL is the /usr/local directory. In that directory, you should find the following:

    lrwxr-xr-x   1 root  wheel   26 Feb  9 20:41 mysql -> mysql-5.5.9-osx10.6-x86_64
    drwxr-xr-x  16 root  wheel  544 Jan 20 13:46 mysql-5.5.9-osx10.6-x86_64

    If you’ve manually installed the files position the directory with the release name, like that shown above. Create a mysql link that points to the directory where you installed the MySQL database home.

    Inside the physical mysql-5.5.9-osx10.6-x86_64directory, you should find these files. Everything should be owned by the root user and have the primary group as wheel group, except for the data files which are owned by the _mysql user.

    -rw-r--r--   1 root    wheel    7390 Jan 19 15:37 INSTALL-BINARY
    -rw-r--r--   1 root    wheel   17987 Jan 19 15:37 COPYING
    -rw-r--r--   1 root    wheel  113534 Jan 19 15:37 README
    drwxr-xr-x   3 root    wheel     102 Jan 20 13:46 scripts
    drwxr-xr-x   4 root    wheel     136 Jan 20 13:46 docs
    drwxr-xr-x   4 root    wheel     136 Jan 20 13:46 man
    drwxr-xr-x   6 root    wheel     204 Feb  9 20:41 ..
    drwxr-xr-x  11 _mysql  wheel     374 Feb 23 19:58 data
    drwxr-xr-x  12 root    wheel     408 Feb  9 20:41 lib
    drwxr-xr-x  16 root    wheel     544 Jan 20 13:46 .
    drwxr-xr-x  16 root    wheel     544 Jan 20 13:46 support-files
    drwxr-xr-x  19 root    wheel     646 Feb  9 20:41 mysql-test
    drwxr-xr-x  28 root    wheel     952 Jan 20 13:46 sql-bench
    drwxr-xr-x  32 root    wheel    1088 Jan 20 13:46 share
    drwxr-xr-x  37 root    wheel    1258 Jan 20 13:46 include
    drwxr-xr-x  44 root    wheel    1496 Jan 20 13:46 bin

    maclochlainn

    23 Feb 11 at 10:12 pm

  8. I couldn’t start the MySQL server after the first initial install using the system preferences pane and I couldn’t start it up using the alias created in the .bash_login file that I created following the instructions in this post either. I went searching around for a solution. The instructions in the following link fixed it for me. Hope this helps.

    http://forums.mysql.com/read.php?11,399397,399606#msg-399606

    Nate

    10 Mar 11 at 7:37 pm

  9. Installed and got the server running. But I can’t seem to login as root with no password.

    ./mysql -uroot
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    Attempted …

    ./mysqladmin -u root password "password"
    ./mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'

    But I’m able to login by just entering ./mysql (no username, no password) but `show databases` doesn’t show mysql.

    amtec

    16 Oct 11 at 9:34 pm

  10. I’d need more information to help you. What version did you download and install?

    It appears that you’ve logged in as the anonymous user and have no permissions to see databases other than the information_schema database. Can you see the information_schema database? Did you provide a password during configuration?

    maclochlainn

    16 Oct 11 at 9:48 pm

  11. What version did you download and install?
    mysql-5.5.13-osx10.6-x86_64.dmg

    Can you see the information_schema database?
    Yes

    Did you provide a password during configuration?
    No

    amtec

    16 Oct 11 at 10:12 pm

  12. The easiest thing is to simply disable security and reset the root password. The instructions for Windows are here. The only difference is that you’ll need to edit the file as root and the file is my.cnf. If you don’t want to do this, then the uglier observation and alternative follows below.

    The good news is that you’re connecting as the anonymous user, the bad news is that root may not exist. You can run the following command inside the information_schema database, and if it returns zero you’ll need to re-install or snag copies of user.MYD.gz, user.MYI.gz, and user.frm from a working instance and put them in the /usr/local/mysql-5.5.13-osx10.6-x86_64/data/mysql directory.

    mysql> SELECT COUNT(*) FROM user_privileges
        -> WHERE  grantee LIKE CONCAT('%','root','%');

    Alternatively, you could opt for the one I installed for the post, which worked well.

    maclochlainn

    16 Oct 11 at 11:35 pm

  13. I have Mac OSX10.7 and Mamp Pro. I was using Mamp Pro trial and it all worked fine, but since I purchased a license key (must be updated version) I can no longer access my WordPress site on localhost. Message says “The requested URL /wordpress/ was not found on this server.”

    Mysql Error Log
    111026 21:26:26 mysqld_safe Starting mysqld daemon with databases from /Library/Application Support/appsolute/MAMP PRO/db/mysql
    111026 21:26:26 [Warning] Setting lower_case_table_names=2 because file system for /Library/Application Support/appsolute/MAMP PRO/db/mysql/ is case insensitive
    111026 21:26:26 [Note] Plugin 'FEDERATED' is disabled.
    111026 21:26:26 InnoDB: The InnoDB memory heap is disabled
    111026 21:26:26 InnoDB: Mutexes and rw_locks use GCC atomic builtins
    111026 21:26:26 InnoDB: Compressed tables use zlib 1.2.3
    111026 21:26:26 InnoDB: Initializing buffer pool, size = 128.0M
    111026 21:26:26 InnoDB: Completed initialization of buffer pool
    111026 21:26:26 InnoDB: highest supported file format is Barracuda.
    111026 21:26:26  InnoDB: Waiting for the background threads to start
    111026 21:26:27 InnoDB: 1.1.5 started; log sequence number 7546283
    111026 21:26:27 [Note] Event Scheduler: Loaded 0 events
    111026 21:26:27 [Note] /Applications/MAMP/Library/bin/mysqld: ready for connections.
    Version: '5.5.9'  socket: '/Applications/MAMP/tmp/mysql/mysql.sock'  port: 0  Source distribution

    I have posted my question in several forums with no solution, and was hoping maybe you might have a suggestion. Thanks for reading my comment.

    Sharon

    26 Oct 11 at 4:50 am

  14. I’d recommend you inspect the httpd.conf to verify that you’ve got a /wordpress/ virtual directory configured. You may also check this MAMP blog post.

    maclochlainn

    26 Oct 11 at 8:53 pm

  15. Excellent instructions. Only two comments:
    (1) Instead of mysql -uroot, I had to type ./mysql -uroot and
    (2) It gave me the error message: “ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”, but then when I typed “./mysql -h 127.0.0.1 -u root -p” and it asked for the password, then it worked…I could login as root.
    Thanks.

    Amrapali

    16 Feb 12 at 3:04 am

  16. Hi,

    I found this post which is really great. I could follow it to the dot until it came to configure the user’s shell environment. First I tried to create the .bash_login file which didn’t exist but the instructions posted never worked, so I managed to create the file myself using BBedit and placing it in the /usr/local/myssql-5.5.22-osx10.6-x86_64 folder. But from there on I just couldn’t move forward.

    When I try to use mysql in a webpage I get a “Could not connect: Access denied for user ‘root’@’localhost’ (using password: YES)” error. I suppose that the problem is that the environment is not correctly set. I’m very new to mac and the terminal. Can anyone help?

    Alegra

    7 May 12 at 8:50 am

  17. I’m not sure from what you’ve written which command isn’t working. Could you provide the command that generates the errors?

    maclochlainn

    9 May 12 at 10:56 pm

  18. Amazing! Thanx a lot!

    Matina

    2 Jun 12 at 10:22 am

  19. I have error too..

    mysql> CREATE DATABASE testforfirst;
    ERROR 1044 (42000): Access denied FOR USER ''@'localhost' TO DATABASE 'testforfirst'

    can you tell detail with specifics instruction and give picture of all not just for install but for before first used my sql..

    Thanks

    Mike

    7 Jun 12 at 2:54 am

  20. Take a look at the bottom of this blog entry.

    maclochlainn

    7 Jun 12 at 8:39 am

  21. [...] the MySQL installation I turned to Michael McLaughlin’s blog. MySQL has a simple implementation for Mac OS X. You can download an OS X Disk Image of [...]

  22. My Mac OS is Lion, I installed the MySQL according to this manual, and when I use the mysqlstart and mysqlstop command, it prompt that

    /Library/StartupItems/MySQLCOM

    is a directory, but the MySQLCOM is a shell script, what happend here? MySQL version is

    MySQL Version 14.14 Distribution 5.5.27, for osx10.6 (i386) using readline 5.1.

    coanor

    19 Sep 12 at 2:09 am

  23. Excellent tutorial! Thanks!

    mang

    22 Sep 12 at 10:01 pm

  24. Very good HowTo! Thx a lot!

    Romain

    22 Oct 12 at 2:01 am

  25. Hi,
    just wanted to say thanks for a quick and concise how-to. I just wanted to get MySQL running quickly on my Mac mini and your information was invaluable.
    Thanks again.

    Scott

    28 Oct 12 at 7:45 pm

  26. One of the better mysql installation on OS X HOWTOs I’ve seen. I would make one change and one addition:

    The aliases for starting and stopping the daemon from the command line should be (adding sudo):

    alias mysqlstart="sudo /Library/StartupItems/MySQLCOM/MySQLCOM start"
    alias mysqlstop="sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop"

    The addition is as follows – the installation does not include a mysql server options file. The server will run without one, but you cannot do the necessary settings tuning for optimal performance. The installation does include samples – you can copy one (use the biggest) to get you started:

    sudo cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf

    Even those suggested settings are too small for modern hardware, but that’s a good education in itself.

    Nice job!

    Don McArthur

    13 Nov 12 at 11:11 am

  27. Don, Thanks for the feedback. It’s incorporated in the post now.

    maclochlainn

    13 Nov 12 at 12:04 pm

  28. maclochlainn, You’re welcome.

    Final tweaks – your aliases mysqlstart and mysqlstop pass the ‘start’ and ‘stop’ arguments to MySQLCOM, so those options don’t need to be used on the cli and are in fact ignored. ‘>mysqlstart’ and ‘>mysqlstop’ are sufficient.

    I’ve also added the following alias because MySQLCOM does not accept an argument of ‘status':

    alias mysqlstatus="ps aux | grep mysql | grep -v grep"

    Look for mysqld and mysql_safe in the output. :-)

    Don McArthur

    14 Nov 12 at 6:37 am

  29. Hi, may i know why my mac terminal shows that the permission is denied when I enter touch .bash_login ?

    sweety

    14 Nov 12 at 6:50 pm

  30. Are you working in a directory owned by your user? Generally, this type of error only occurs when you try to touch a file in a directory you don’t own.

    This should work in any directory:

    sudo touch .bash_login

    maclochlainn

    14 Nov 12 at 9:03 pm

  31. Don, Thanks, again. I’ve added it to the post.

    maclochlainn

    14 Nov 12 at 11:52 pm

  32. Why does it sayE45: ‘readonly’ option is set (add ! to override), when I try to enter the given contents into the file .bash_login using vi editor?

    sweety

    15 Nov 12 at 10:43 pm

  33. Please check the following file:

    ls -al .bash_login

    It should find that file with the following permissions:

    -rw-r--r--  1 macuser  staff  254 Feb 21  2011 .bash_login

    Check if that’s your user name with:

    whoami

    If it’s not got those permissions, you should be able to assign those permissions:

    chmod 644 .bash_login

    Hope this helps. If not post a followup question.

    maclochlainn

    16 Nov 12 at 12:51 am

  34. Hi, I did type ls -al .bash_login, but it does not show any mac user name as you said. It just enters as following,

    -rw-r--r--  1 root  wheel  0 Nov 16 10:20 .bash_login

    However, it does not allow me to edit with vi the file once again.

    sweety

    16 Nov 12 at 8:24 am

  35. Hey the ls -al .bash_login worked for me. But, the further displays this way:

    Last login: Fri Nov 16 13:00:48 on ttys001
    Laxmis-MacBook-Pro:~ laxmipandrapragada$ cat .bash_login
    #Set the MySQL Home environment variable to point to the root directory of the MySQL installation.
    export set MYSQL_HOME=/usr/local/mysql-5.5.16-osx10.6-x86_64
     
    # Add the /bin directory from the MYSQL_HOME location into your $PATH environment variable.
    export set PATH=$PATH:$MYSQL_HOME/bin
     
    # Create aliases that make it easier for you to manually start and stop the MySQL Daemon.
    alias mysqlstart="sudo /Library/StartupItems/MySQLCOM start"
    alias mysqlstop="sudo /Library/StartupItems/MySQLCOM stop"
     
    # Set the MySQL Home environment variable to point to the root directory of the MySQL installation.
    export set MYSQL_HOME=/usr/local/mysql-5.5.18-osx10.6-x86_64
     
    # Add the /bin directory from the MYSQL_HOME location into your $PATH environment variable.
    export set PATH=$PATH:$MYSQL_HOME/bin
     
    # Create aliases that make it easier for you to manually start and stop the MySQL Daemon.
    alias mysqlstart="sudo /Library/StartupItems/MySQLCOM/MySQLCOM start"
    alias mysqlstop="sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop"
    alias mysqlstatus="ps aux | grep mysql | grep -v grep"

    Why do these happen?

    Laxmis-MacBook-Pro:~ laxmipandrapragada$ ./.bash_login
    -bash: ./.bash_login: Permission denied
    Laxmis-MacBook-Pro:~ laxmipandrapragada$ . ./.bash_login
    Laxmis-MacBook-Pro:~ laxmipandrapragada$

    After closing the terminal and reopening it and typing which -a mysql, it displays this way:

    Laxmis-MacBook-Pro:~ laxmipandrapragada$ which -a mysql
    Laxmis-MacBook-Pro:~ laxmipandrapragada$

    But, does not return the path as you said. Please let me know the case.

    sweety

    16 Nov 12 at 11:05 am

  36. Can you let me know which Mac OS X you’re running? You can find it at the terminal like this:

    sw_vers -productVersion

    Is the machine yours or a company machine? If the latter, it appears they’ve changed ownership of files. However, it appears your user is in the sudoer group. That means you should be able to edit it by using sudo or creating a root shell. You create a root shell as a sudoer with this syntax:

    sudo sh

    maclochlainn

    16 Nov 12 at 11:27 am

  37. It is 10.7.5. It is my laptop and not a company machine.

    sweety

    16 Nov 12 at 1:06 pm

  38. May I know how do I do it for 10.7.5 mac OS owned by me please?

    sweety

    16 Nov 12 at 7:10 pm

  39. Its unclear how the file ownership changed from the default settings but they should be as noted earlier. The best way to precede is to know whence you came. Did you issue a chown command in the home directory? You can run the following command from the default terminal location, which should be your home directory:

    pwd

    It should return, the following where macuser is your user name:

    /Users/macuser

    Determine if you changed one or all files by issuing an ls -al command in your home directory. In the listing, it appears you may see results like the following:

    drwxr-xr-x+ 44 macuser  staff     1496 Nov 16 22:25 .
    drwxr-xr-x   5 root     admin      170 Aug 29  2009 ..
    -rw-------   1 root     wheel        3 Sep 13  2008 .CFUserTextEncoding

    The ownership displayed for the . (dot) or present working directory, should be the ownership for everything in that directory. That includes subdirectories (or folders). If you see that all files have a root owner and wheel default group, change them back to what they should be in a normal Mac OS X installation. You need to act as sudoer or root to make the change back. This command should do that for you, and enable you to complete the instructions.

    chown -R macuser:staff *

    This should fix your problem. If it doesn’t let me know.

    maclochlainn

    16 Nov 12 at 10:40 pm

  40. As you said, the following is the resultant:

    Laxmis-MacBook-Pro:~ laxmipandrapragada$ pwd
    /Users/laxmipandrapragada
    Laxmis-MacBook-Pro:~ laxmipandrapragada$ ls -al
    total 264
    drwxr-xr-x+  38 laxmipandrapragada  staff   1292 Nov 16 12:49 .
    drwxr-xr-x    6 root                admin    204 May 24 10:38 ..
    -rw-------    1 laxmipandrapragada  staff      3 Jan 28  2012 .CFUserTextEncoding
    -rw-r--r--@   1 laxmipandrapragada  staff  21508 Nov 14 19:43 .DS_Store
    drwx------    5 laxmipandrapragada  staff    170 Nov 15 09:04 .Trash
    -rw-r--r--    1 laxmipandrapragada  staff    140 Oct  8 18:31 .appletviewer
    -rw-------    1 laxmipandrapragada  staff   7080 Nov 16 15:14 .bash_history
    -rw-r--r--    1 laxmipandrapragada  staff   1085 Nov 16 12:49 .bash_login
    -rw-------    1 laxmipandrapragada  staff   1760 Nov 13 12:10 .mysql_history
    drwxr-xr-x    3 laxmipandrapragada  staff    102 Oct  1 01:19 .netbeans-derby
    -rw-r--r--    1 laxmipandrapragada  staff    241 Sep 13 16:12 .profile
    -rw-------    1 laxmipandrapragada  staff      4 Nov 14 10:23 .sh_history
    -rw-------    1 laxmipandrapragada  staff  12288 Sep 13 12:08 .swp
    -rw-------    1 laxmipandrapragada  staff   3554 Nov 16 12:49 .viminfo
    -rw-r--r--    1 laxmipandrapragada  staff    300 Oct 11 11:36 1.c
    drwx------+  16 laxmipandrapragada  staff    544 Nov 16 13:02 Desktop
    drwx------+  12 laxmipandrapragada  staff    408 Nov  2 22:42 Documents
    drwx------+ 213 laxmipandrapragada  staff   7242 Nov 16 00:58 Downloads
    drwx------@  48 laxmipandrapragada  staff   1632 Oct  1 00:47 Library
    drwx------+   6 laxmipandrapragada  staff    204 May 29 09:28 Movies
    drwx------+   6 laxmipandrapragada  staff    204 May  8  2012 Music
    drwxr-xr-x    5 laxmipandrapragada  staff    170 Oct  1 01:45 NetBeansProjects
    drwx------+   8 laxmipandrapragada  staff    272 Mar  9  2012 Pictures
    drwxr-xr-x+   5 laxmipandrapragada  staff    170 Jan 28  2012 Public
    -rwxr-xr-x    1 laxmipandrapragada  staff   8784 Oct 11 11:36 a.out
    -rw-r--r--    1 laxmipandrapragada  staff    303 Oct 10 09:45 c.c
    -rw-r--r--    1 laxmipandrapragada  staff     77 Sep 20 00:51 demo.c
    -rw-r--r--    1 laxmipandrapragada  staff    576 Sep 30 23:48 f
    -rw-------    1 laxmipandrapragada  staff    578 Sep 30 23:51 f.save
    -rw-r--r--    1 laxmipandrapragada  staff      0 Nov 14 20:26 f1
    -rw-r--r--    1 laxmipandrapragada  staff    757 Oct 18 13:40 main.c
    -rw-r--r--    1 laxmipandrapragada  staff      4 Nov 16 00:37 my
    drwxr-xr-x    3 laxmipandrapragada  staff    102 Sep 13 11:39 newdirectory
    -rw-r--r--    1 laxmipandrapragada  staff     36 Sep 13 11:57 newfile
    -rw-------    1 laxmipandrapragada  staff     17 Sep 13 10:44 newfile.save
    drwxr-xr-x    3 laxmipandrapragada  staff    102 Sep 24 13:22 project1
    -rwxr-xr-x    1 laxmipandrapragada  staff   8736 Sep 23 10:48 try
    -rw-r--r--    1 laxmipandrapragada  staff    134 Sep 26 20:02 try.c

    sweety

    16 Nov 12 at 11:01 pm

  41. Now, please let me know what is the next procedure I am supposed to take. Thank you.

    sweety

    16 Nov 12 at 11:03 pm

  42. Aren’t you able to use vi to edit the .bash_login file now?

    maclochlainn

    16 Nov 12 at 11:32 pm

  43. I installed mysql 5.5.28. So, which version shall I edit in the vi file? Is it the same that you entered in the installation steps i.e.,

    #Set the MySQL Home environment variable to point to the root directory of the MySQL installation.
    export set MYSQL_HOME=/usr/local/mysql-5.5.16-osx10.6-x86_64
     
    # Add the /bin directory from the MYSQL_HOME location into your $PATH environment variable.
    export set PATH=$PATH:$MYSQL_HOME/bin
     
    # Create aliases that make it easier for you to manually start and stop the MySQL Daemon.
    alias mysqlstart="sudo /Library/StartupItems/MySQLCOM start"
    alias mysqlstop="sudo /Library/StartupItems/MySQLCOM stop"

    Or am I supposed to make changes to that in vi file? Please let me know.

    sweety

    17 Nov 12 at 7:55 am

  44. Could you please let me know what contents do I need to enter in the vi file for Mac 10.7.5 with mysql 5.5.28 version?

    sweety

    17 Nov 12 at 9:36 am

  45. First, let’s make sure you know where the directory for the MySQL home is:

    ls /usr/local/mysql*

    Let’s assume that returns mysql-5.5.28-osx10.6-x86-64 as a result, then you should enter this in your .bash_login file:

    # Set the MySQL Home environment variable to point to the root directory of the MySQL installation.
    export set MYSQL_HOME=/usr/local/mysql-5.5.28-osx10.6-x86_64
     
    # Add the /bin directory from the MYSQL_HOME location into your $PATH environment variable.
    export set PATH=$PATH:$MYSQL_HOME/bin
     
    # Create aliases that make it easier for you to manually start and stop the MySQL Daemon.
    alias mysqlstart="sudo /Library/StartupItems/MySQLCOM/MySQLCOM start"
    alias mysqlstop="sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop"
    alias mysqlstatus="ps aux | grep mysql | grep -v grep"

    Hope this helps you …

    maclochlainn

    17 Nov 12 at 12:12 pm

  46. I have mysql v5.4.4 on my mac working as a local host. I am receiving an error message, but the website I am working on works fine on the remote server. I discovered the remote server is running 5.1.66. So, I want to install that version on my mac to match the remote server. Any suggestions? Will I run into any difficulties? I can download the 5.1.66 version. By the way, I established the local server using MAMP.

    William

    17 Nov 12 at 3:49 pm

  47. I don’t think that you should. Let me know if you do?

    maclochlainn

    17 Nov 12 at 4:21 pm

  48. I get this now when I open my vi file..

    E325: ATTENTION
    Found a swap file by the name ".bash_login.swp"
              owned by: laxmipandrapragada
                 dated: Sat Nov 17 10:34:59 2012
             file name: ~laxmipandrapragada/.bash_login
              modified: YES
             user name: laxmipandrapragada
             host name: Laxmis-MacBook-Pro.local
            process ID: 5677 While opening file ".bash_login"
                 dated: Sat Nov 17 10:10:52 2012

    (1) Another program may be editing the same file.
    If this is the case, be careful not to end up with two
    different instances of the same file when making changes.
    Quit, or continue with caution.

    (2) An edit session for this file crashed.
    If this is the case, use “:recover” or “vim -r .bash_login”
    to recover the changes (see “:help recovery”).
    If you did this already, delete the swap file “.bash_login.swp”
    to avoid this message.

    Swap file “.bash_login.swp” already exists!
    [O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

    How do I solve this case? Please let me know..

    sweety

    17 Nov 12 at 10:19 pm

  49. You can delete the *.swp file. It’s a temporary file, like those created by word processing software. Alternative, choose edit anyway.

    maclochlainn

    17 Nov 12 at 11:11 pm

  50. Thanks you for your patience. I finished doing all the installation steps as above. But, once I restarted the terminal, it shows an error:

    Laxmis-MacBook-Pro:~ laxmipandrapragada$ mysql -uroot
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    Please let me know how to resolve the case.

    sweety

    18 Nov 12 at 7:29 am

  51. That’s not a bad message because it says the MySQL (mysqld process) is running. It says you have a password set for the instance. My assumption is that you don’t know the password, but if you do the easiest thing is to connect this way:

    mysql -uroot -ppassword

    If you don’t have the password, you can use this post on resetting the MySQL root account. The only difference is that on Windows the option file is my.ini, whereas on Mac OS X it is my.cnf.

    maclochlainn

    18 Nov 12 at 10:08 am

  52. [...] Mac OS X, Mountain Lion (10.8.x), requires some pre-steps [...]

  53. Hi, just wanted to say thanks for the nice work. I’ve followed each step and mysql is working perfectly on my machine. The only problem i’m facing is alias “mysqlstart” is not working for me, else all other aliases are working fine for me like “mysqlstop”, “mysqlstatus”. I even added one more alias “mysqlrestart” and its also working perfectly fine.

    What could be the reason for “mysqlstart”? am i making any mistake here? Version of my OS X is 10.8.2

    Thanks in advance for your help.

    Regards, Jagdish

    Jagdish

    11 Dec 12 at 2:19 am

  54. Can you post your .bash_login contents?

    maclochlainn

    11 Dec 12 at 11:05 am

  55. Hi,

    I get the following error message:
    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2)

    I downloaded mysql-5.5.29-osx10.6-x86_64.dmg and installed according to the instructions above.

    I run a Mountain Lion (10.8.2) Server (MacMini Server).

    I installed it with the admin account.

    The file ‘/var/mysql/mysql.sock’ do exist.
    I think I’ve tried everything but still have this issue. :)

    Would appreciate the help!

    Sincerely,
    Andreas

    Andreas

    24 Dec 12 at 2:36 pm

  56. Andreas,

    Could you run this to confirm that the MySQL daemon is running?

    ps aux | grep mysqld

    Let me know, thanks.

    maclochlainn

    24 Dec 12 at 10:09 pm

  57. Hi Maclochlainn,

    thank you for taking time to answer.
    When I run the above mentioned command, I get the following output:

    iserver:~ admin$ ps aux | grep mysqld
    admin          16691   0,0  0,0  2432768    588 s000  S+    9:58am   0:00.00 grep mysqld

    I would guess that the MySQL daemon is not running?

    Sincerely,
    Andreas

    Andreas

    25 Dec 12 at 1:59 am

  58. Andreas, That’s right the MySQL daemon isn’t running. The command to start it is noted above.

    maclochlainn

    25 Dec 12 at 9:45 am

  59. Merry Christmas by the way! :)

    I’ve tried the mysqlstart command that has been added in the .bash_login file. Nothing happens.

    I’ve also tried “mysqlstatus” but that returns nothing either.
    I checked in System Preferences and noticed that the MySQL added preference shows that “MySQL Server Instance is stopped” and when clicking “Start MySQL Server” it asks for my user password (Administrator which I am logged in with and installed it with) but then nothing happens at all.

    What to do now?
    Any log that I can read what goes wrong maybe?
    Or should I remove (uninstall) everything and try again?

    I am very thankful for your support!

    Sincerely,
    Andreas

    Andreas

    25 Dec 12 at 10:24 am

  60. Andreas,

    A belated Merry Christmas. Could you run these commands from the Terminal:

    cd /Library/StartupItem
    ls -a

    If you find a MySQLCOM directory, change into that directory and list it’s contents.

    Thanks,
    Michael

    maclochlainn

    26 Dec 12 at 11:52 pm

  61. Great post.
    I was foolishly copied this line

    export set MYSQL_HOME=/usr/local/mysql-5.5.16-osx10.6-x86_64

    and was wondering why it is not working. My version was little different.

    Satya

    30 Dec 12 at 11:28 pm

  62. Satya, I think you already made the change but if not you should put the directory name in that path changes with release.

    maclochlainn

    31 Dec 12 at 9:34 am

  63. thanks so much for such a thorough instruction! best I’ve seen!

    Chelsea

    1 Jan 13 at 8:01 pm

  64. Hello there,
    It was a great post. I followed the instructions as is and I installed
    mysql-5.6.9-rc-osx10.7-x86_64.dmg from developer tools.

    I set the MYSQL_HOME accordingly. After I changed the security passwords and copying the conf file. For this package the

    sudo cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf

    I used my-default.conf instead of my-huge.cnf.

    I logged out and stopped the MySQL Server from the window and started the server with mysqlstart, I get the below error when I type the

    mysql -uroot 
     
    sudheer-kilaru-3:tmp skilaru$ mysql -uroot
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    sudheer-kilaru-3:tmp skilaru$ mysql -uroot -psudheer
    Warning: Using a password on the command line interface can be insecure.
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    sudheer-kilaru-3:tmp skilaru$

    I think I need the correct config file. Can you tell me where I can find the correct config file for this version.
    Jyothi

    Jyothi

    18 Jan 13 at 3:33 am

  65. Can you check if the mysqld process is running?

    ps -ef | grep mysqld

    maclochlainn

    28 Jan 13 at 11:17 pm

  66. After following these steps I had problem starting MySql server from command line because of which I was getting this error when I try to connect:

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

    So I changed my aliases to:

    alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
    alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'

    now it is working fine.

    Also I have done this:

    sudo cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

    Shashank

    3 Feb 13 at 2:56 am

  67. Great update, thanks!

    maclochlainn

    3 Feb 13 at 10:37 am

  68. Dear maclochlainn,

    thank you very much for your detailed instructions. I think I have come pretty far, but like Jyothi, I did not think I had the right .cnf file. I also used my-default.cnf instead. Then I entered the 2 alias lines from Shashank. Now the server is starting and stopping perfectly with mysqlstart and mysqlstop respectively. So a big thank you to all.

    Richard

    Richard

    23 Feb 13 at 8:07 am

  69. Exellent post! Thanks!

    Anders

    26 Feb 13 at 3:05 am

  70. It is a very nice posting. Sashank’s tip helped me when i was struggling for the same error. It saved me a lot of time.

    Mac: Appreciate if you can update the steps with the new inputs from Sashank.

    great posting!!!

    Srini Kadiyala

    28 Feb 13 at 3:45 am

  71. You can’t imagine how thankful I am for this blog post of yours. Moving from Windows, configuring MySQL on MAC has been a nightmare just because of the permissions. Your detailed instructions helped me try to understand why I am doing what. The only changes I need to made was Shashank’s way of adding aliases. I configured this on a Mac 10.8. A big thank you to all. I think I literally encountered all the errors everyone has got.

    HJR

    2 Mar 13 at 12:36 pm

  72. I got a chance to update the post today. Let me know if you think it works?

    maclochlainn

    2 Mar 13 at 2:01 pm

  73. Thanks, I’ve updated the post with the new aliases.

    maclochlainn

    2 Mar 13 at 2:02 pm

  74. These are the instructions that should be on the official MySQL website. Great job! If only all tech setup instructions were this clear and helpful. many thanks maclochlainn.

    Carlos

    10 Mar 13 at 12:19 pm

  75. These instructions are excellent and got mySQL up and running on my iMac easily and quickly. Thanks so much for posting these instructions maclochlainn

    Terry

    13 Apr 13 at 4:17 pm

  76. I did all the way to the command . ./.bash_login
    the answer was: -bash: ./.bash_login: No such file or directory
    and for which -a mysql
    there wasn’t any response at all.

    i am using mountain lion 10.8.3
    installing mysql version mysql-5.6.11-osx10.6-x86_64

    i am totally new into mac, but i used to work on linux before….long time ago….so i forgot some of the basics…

    my questions are:
    where .bash_login should be create (under which path)
    after i edited the .bash_login how should i restart the shell
    why both commands don’t have response like you wrote here

    Jonny

    16 May 13 at 12:10 am

  77. It should be in your user’s home directory:

    /Users/username

    maclochlainn

    17 May 13 at 5:46 pm

  78. thanks, i moved my .bash_login to /Users/myusername and now i can start and stop mysql server from mysqlstart and mysqlstop command, also mysqlstatus works.
    but which -a mysql have no any response.
    can you help me with that please?

    my .bash_login path is # Set the MySQL Home environment variable to point to the root directory of the MySQL installation.
    export set MYSQL_HOME=/usr/local/mysql-5.5.11-osx10.6-x86_64

    # Add the /bin directory from the MYSQL_HOME location into your $PATH environment variable.
    export set PATH=$PATH:$MYSQL_HOME/bin

    Jonny

    19 May 13 at 3:14 am

  79. ok i found my mistake it was the mistake in the path itself/usr/local/mysql-5.5.11-osx10.6-x86_64
    instead of/usr/local/mysql-5.6.11-osx10.6-x86_64
    but now when i write echo $PATH it also return me the/usr/local/mysql-5.5.11-osx10.6-x86_64
    and /usr/local/mysql-5.6.11-osx10.6-x86_64
    how to delete it

    Jonny

    21 May 13 at 1:34 am

  80. Hi-
    I have installed 5.6.11 on Mac OS 10.8.3. Install seemed to go OK, but I have the following issue.
    If I try to get to mysql without specifying a host, or by specifying localhost, I get the following error:

    mysql -uroot
    Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

    mysql -uroot -hlocalhost
    Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

    But if I specify a numeric host, it works fine-
    mysql -uroot -h127.0.0.1

    mysql>

    Any thoughts as to what might be causing this? And how I could fix it? Ideally, I would not need to specify a host when connecting to a local db…

    jim

    21 May 13 at 4:18 pm

  81. What’s in your /etc/hosts file?

    maclochlainn

    24 May 13 at 12:00 am

  82. I also have Jim’s problem of 21 May 13. I’m using mysql version 5.6.11-osx10.6-x86_64. Please help.

    Richard

    30 May 13 at 1:19 pm

  83. thnx!

    gfr

    6 Jun 13 at 3:29 am

  84. after i installed mysql, and it is work correctly, i tried to edit my.cnf to the mysql.sock
    but then mysql server won’t start and have an error
    my.cnf is:

    [mysqld]
     
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
     
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
     
    # These are commonly set, remove the # and set as required.
    #basedir = /usr/local/mysql
    #datadir = /usr/local/mysql/data
    port = 3306
    # server_id = .....
    socket = /var/mysql/mysql.sock
     
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
     
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
     
    [client]
    port = 3306
    socket = /var/mysql/mysql.sock

    and in my shell i got this message:
    .. ERROR! The server quit without updating PID file (/usr/local/mysql/data/Jonny.local.pid).

    please help

    Jonny

    19 Jun 13 at 1:20 pm

  85. I also had the same issue when I first setup MySQL:

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

    However, this only happened when I had MySQL.server turned off. I also had to adjust my aliases based on how my /usr/local/ folder was setup in order for the aliases to work.

    ex:

    alias mysqlstart='sudo $MYSQL_HOME/support-files/mysql.server start'
    alias mysqlstop='sudo $MYSQL_HOME/support-files/mysql.server stop'

    After making the changes in .bash_login I had to run the script again. I then could type in the commands to start and stop the server. Hopefully this may help with your /tmp/mysql.sock’ problem. Check to make sure the servers up and running in your System Preferences pane. Hope this is the only reason why it’s not working.

    Jeremiah F

    19 Jun 13 at 9:09 pm

  86. Macbook crashed when I downloaded MySQL:

    Would be grateful for any advice please.
    Yesterday I downloaded MySQL server from the website to my MacBook Air. I followed the instructions but something went wrong at the final instructions when I launched the terminal session from my utilities.

    I entered the code:

    cd /Library/StartupItems/MySQLCOM
    ls - al
    sudo chown root: wheel *
    cd ..
    sudo chown root:wheel MySQLCOM
    touch .bash_login

    Then I stopped and closed my computer. When I put it on all my files had gone and the settings were changed. It has gone back to basic/original mode.

    I’m a student and new at this and just use it as part of my course.

    I need to put my Mac back to its original settings and if there’s a way of recovering my photos etc…? Don’t know what code/ command I need to use.
    Thank you.

    Leo

    26 Jun 13 at 1:37 pm

  87. So using Mountain Lion (OSX 10.8) and MySQL 5.6.12 and I’m good up until the setting of the passwords. For some reason this part:

    SET PASSWORD FOR 'root'@'MacPro.local' = password('cangetin');

    is giving me an error

    ERROR 1032 (HY000): Can't find record in 'user'

    I’ve been able to reset the other 3 passwords, however .local is giving me a tough time. Anyone know what could be the issue?

    I’m also having some difficulty with the mysqlstart and mysqlstop commands, as I receive a

    sudo: /Library/StartupItems/MySQLCOM: command not found

    Is this because of the 5.6.12 build differing from whats above for the 5.5 build?

    Thanks for the help!

    Ricky

    2 Jul 13 at 1:56 am

  88. Ricky, while I try to keep this current, it appears I’ve a new test to run. Unfortunately, I can’t do it immediately. Verify whether or not that’s the correct directory. You can poke around as root by using this command:

    sudo sh

    It’ll prompt you for your administrator password and start a BASH shell as the root user. Hope this helps until I can provide another more detailed update.

    maclochlainn

    13 Jul 13 at 11:03 am

  89. I am also unable to
    SET PASSWORD FOR ‘root’@’MacPro.local’ = password(‘cangetin’);

    Keithia

    14 Jul 13 at 11:57 pm

  90. Keithia, The syntax should work if you’re connected as root or you’ve disabled authentication. Please take a look at this other post and see if you can reset the my.ini or my.cnf file and try again.

    maclochlainn

    15 Jul 13 at 12:17 am

  91. [...] found this blog which explains things a little more clearly if you are confused by MySQL documentation After [...]

  92. ERROR 1032 (HY000): Can't find record in 'user'

    I installed MySQL 5.6 on OS X 10.8.4 using the instructions given here and encountered the same issue when trying to set the password of MacBook-Pro.local by using:

    SET PASSWORD FOR ‘root’@'MacBook-Pro.local’ = password(‘abc’);

    Then, I tried:

    UPDATE mysql.user SET Password = PASSWORD('newpwd') WHERE User = 'root';
     
    FLUSH PRIVILEGES;

    It has worked perfectly. The FLUSH statement causes the server to reread the grant tables. Without it, the password change remains unnoticed by the server until you restart it (reference).

    Maryam

    11 Aug 13 at 11:24 am

  93. Maryam,

    You might find this helpful on resetting the MySQL root password.

    maclochlainn

    12 Aug 13 at 7:57 pm

  94. sudo /usr/local/mysql/support-files/mysql.server start
    Starting MySQL
    . ERROR! The server quit without updating PID file (/usr/local/mysql/data/E8025JEQIUT.local.pid).

    My laptop crashed after that when ever i try to start it i am getting this ERROR

    newbie

    29 Aug 13 at 3:33 pm

  95. Newbie, Try this, which creates a root shell.

    sudo sh

    maclochlainn

    29 Aug 13 at 11:58 pm

  96. […] chose the default folder, you may have to change the mySQL version! (I did kind of steal this from here.. with some amendments of […]

  97. […] There are a number of tutorials on installing on OSX … This one works: MacLochlainns Weblog […]

  98. Hi,

    Article helps lot, thanks for this.

    One question.

    Followed the steps and it is working fine after all steps done, but when I shutdown system and start it again on next day then mysqlstart,mysqlstop,mysqlstatus commands are not working again.

    Anything else I need to do ?

    Thanks,

    Ranjit

    9 Mar 14 at 10:21 pm

  99. Ranjit, do you notice anything that might help diagnose your problem?

    maclochlainn

    10 Mar 14 at 1:38 am

  100. […] installing MySQL is beyond the scope of this tutorial […]

  101. […] run MySQL Workbench and MySQL server natively on the Mac OS X […]

  102. Thank you so much for your instructions.

    Worked like a charm and helped me have an easier night!!

    Thx!

    Jose

    26 May 14 at 8:10 pm

Leave a Reply