mac - I just installed MAMP. How do I access mysql through the terminal?

02
2013-08
  • Questioner

    I'm trying to figure out how I can start using mysql through terminal since I'm not much of a fan for phpmyadmin.

    I read online where that told me to type this into terminal

    /Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
    

    and I did and received this

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    

    I've already setup the permissions through phpmyadmin

    What can I be doing wrong, the guy in the tutorial didn't say that I had to include my login/pass anywhere in that link, I also did try including my login/pass and it still wouldn't work, it wouldn't execute, just display the help page for mysql.

    What's a good third party application that would let me create tables, and work with MySQL? When I was using Windows I would use mysql maestro and it would do the job really well. Since I'm new to the Mac, what is out there?

  • Answers
  • Tomas Markauskas

    Try --host=127.0.0.1 because the mysql client is trying to connect using the standard mysql socket (/tmp/mysql.sock). Specifying an IP address won't use this socket connection. I had to change this in every program to be able to connect to the MAMP database, including Sequel Pro.

  • MDMarra

    I suggest using Sequel Pro for all your Mac SQL DB GUI needs.

    As for why your access is deined,

    • Can you login to phpMyAdmin using root/root?
    • What happens when you leave off the --host= portion?
  • dcneiner

    You should leave off the --host part or add --port=8889 but don't use just --host. By including --host without --port you might be trying to connect to another MySQL installation running at the default 3306.

    It is possible that you changed the mysql root password during installation. Typing it this way will prompt you for your password, or you could enter the changed password as needed:

    /Applications/MAMP/Library/bin/mysql -uroot -p
    

    Also, Sequel Pro is one of the nicest free solutions for the Mac. I use it all the time. To connect to MAMP with Sequel Pro, use the following settings:

    host: 127.0.0.1

    user name: root

    password: root (or if you changed it, whatever that is)

    port: 8889

  • Kaji

    Good luck, I tried to get MAMP to work and gave up on it. Nothing worked trying to get MySQL up and running on my machine until I installed XAMPP, which was surprisingly painless and trouble free. No additional configuration required once you have it set up, except for using its control panel application to start and stop the components you want to run at the moment.

  • Ivan Chaer

    Just posted on Stack Overflow a solution for a similar problem. Thought it might help someone to post it here as well.

    I was trying to access MAMP's MySQL through the terminal on Mountain Lion, and getting the same ERROR 1045 (28000).

    The --no-defaults flag solved it for me.

    /Applications/MAMP/Library/bin/mysql --no-defaults -u root -proot -h localhost
    

  • Related Question

    Installing Apache/MySQL/PHP on Mac OS X Snow Leopard without a direct internet connection
  • Moshe

    Are there any good sites that explain the process in such a way that it can be done on a Mac without internet? I would put the installers on a USB drive and move them from an internet enabled machine.

    I found this site, but it's a bit much. I'm not up for compiling things...

    http://adylitica.com/2009/11/24/installing-amp-apache-mysql-php-on-mac-os-x-10-6-snow-leopard/

    EDIT:

    I once used MAMP and I didn't like it too much. What about the built in stuff? (which I just discovered via Google.)

    edit2: XAMPP works well but I cant seem to get proper permissions for the htdocs folder. I tried chmod -R -L 775 htdocs and it is not working. I want to be able to dra and drip on finder...


  • Related Answers
  • Josh K

    You can use something like XAMPP or MAMP if you don't want to compile stuff.

    You can copy them to a USB drive and install them to the target host.

  • Loïc Wolff

    You could use MAMP.

    Just download the .dmg file, put it on the USB drive and install it wherever you want.

    EDIT:
    If you don't want to use MAMP, this question answer what you want: Apache + PHP via built in Mac OS X and MySQL installed on the side.