Mamp Mysql Command Line




.profile - error in MySQL path - Mac command line - MAMP
Posted by: Stefan Gold
Date: September 11, 2009 09:57PM

Hey there,
i was going to write a new path to MySQL into the .profile document on my Mac, so that i can access MySQL simply through typing 'mysql' into the command line and not having to write the whole path each time. Here is what i wrote in .profile:
PATH=$PATH:/Application/MAMP/Library/bin/
export PATH
But i made a spelling mistake in the path, and now it seems that i can't change it in the .profile document anymore. I would always get this error msg in terminal:
Last login: Sat Sep 12 11:32:36 on ttys000
You have new mail.
-bash: export: `/Application/MAMP/Library/bin': not a valid identifier
110:~ appleuser$ mysql
-bash: mysql: command not found
110:~ appleuser$
Is there a way to get that changed?
Thanks so much for your help!
honorfield
Edited 1 time(s). Last edit at 09/11/2009 11:13PM by Stefan Gold.

Options:Reply•Quote

  1. B) check you can connect to mysql via the command line, ie $ mysql -u root -p c) check your database connection settings (in the wordpress folder - ie in wp-config.php).
  2. MySQL from the Command Line (terminal) in MAMP PRO Posted on October 9, 2011 Author Paul Leasure No Comments on MySQL from the Command Line (terminal) in MAMP PRO To get to the command line for MySQL for MAMP or MAMP PRO just open up you terminal and enter the following.
  3. Preferences MySQL. The MySQL database server is a popular database used on production servers. MAMP comes installed with MySQL 5.6.x.

AppleScript to start MAMP’s Apache and MySQL servers using the security command in Terminal. Save this AppleScript as an AppleScript application and add it to the user’s Login Items and MAMP’s Apache and MySQL servers will be up and running when user login is complete.

Phone

Written By
.profile - error in MySQL path - Mac command line - MAMP
September 11, 2009 09:57PM
Re: .profile - error in MySQL path - Mac command line - MAMP
September 11, 2009 11:13PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.

Coming from a Linux background, one of the things I didn’t like about MAMP was the way it hid away the mysql command line interface. Once you are comfortable using it, the CLI is a powerful and quick method of interacting with a mysql server. I just wanted to share a quick and easy way to access the MAMP mysql command line client on Mac OSX.

Firstly you can run the Mac OSX terminal easily by just typing:

ctrl + space bar (to access spotlight)

Then start typing ‘Terminal’ before you have even finished the little Apple gnomes will have guessed you want to open the Terminal (which of course you do). Start the Terminal by hitting enter when spotlight highlights the Terminal app.

Now that you are in a Terminal you are able to do all sorts of excellent things to your Mac. For now though, we’ll stick to running the mysql client. The client is located in /Applications/MAMP/Library/bin so to run it execute this command:

The -uroot tells the client you want to log in as user ‘root’ if you have other users you could equally log in as those. The -p tells the client to ask for a password, you can pass the password to the client so it won’t ask, but this will leave your password dangling in places like your bash history file. If you don’t care about that – then by all means change the -p to -psecret where your password replaces ‘secret’.

Mamp Mysql Command Line Commands

If you leave the -p as it is, you’ll be prompted for your password, which you can see on the MAMP ‘start page’ in case you have forgotten. If you have done it right you should now see a command line prompt like this:

This is where the magic happens. I won’t go in to too much detail because there are roughly 2 million mysql books in existence, testament to the fact there is a lot to cover, far more than I could get through in a single blog post. However, to give you a few commands to try out, here are a handful of useful mysql commands.

Where database_name is the name of the database you are interested in inspecting/changing. This sets the client context to given database. You can pass a database name as an argument to the client, to pre-set the context. For example:

Will implicitly set the client to use ‘my_db’ when it starts, so that you do not have to type the USE command.

This command will print a list of tables in the current database. This is useful if you are trying to figure out what tables exist in a new database, or to find out if there is some sort of logging table (e.g. the Google Checkout logging table in Magento) that might be useful.

Mamp start mysql command line

To get an idea for how big a table is (in terms of row count) you can run a quick:

This will report how many rows are in the table named table_name. This can be useful if you are about to select * from the table, because it might save you spamming your terminal full of query output.

Mamp Mysql Command Line

One last handy little trick is the formatting for query output. By default it will come out in row format which, for queries with lots of result rows or lots of selected columns, can be hard to read. By replacing the semi-colon ; at the end of a query with a G you can cause the output to be made vertical in the format field:value.

Mysql Command Line Download

For example:

Mamp Mysql Command Line

Will show all the rows from table_name in a more easily readable vertical format.

Extra for Experts: adding a local bin dir to make running MySQL easier

Mysql command line show tablesLine

Based on comment feedback from daffy I’m adding a little guide to make running mysql easier.

Firstly make a directory for your local bin:

Mamp Mysql Command Line

Now link the mysql binary (and as many others as you want) in to this directory.

Lastly edit your .bash_profile file (it’s in your home directory) and add the following line in order to add your new local bin directory to your path:

Then add this line – but if you already have a PATH declaration, you can just add it to the end of that:

Using Mysql Command Line With Mamp

Now you can run MySQL by just typing mysql Mac os x mountain lion free download dmg. on the terminal command line.

Troubleshooting:
1) Check your PATH contains your local bin:

2) Check your bin directory has the link correctly:

3) Check the mysql being run is the one from your local bin:

In Firefox version 66.0.4 when I download a.jnlp-file it provides the option to either save the file or open it in Java Web Start. Now that I updated to Firefox version 67.0 I can only save the file. The option to directly open the file using Java Web Start is not available anymore. Jnlp linux mint. A If you have JRE (Java Runtime Environment) installed, you can follow these steps to configure Firefox browser to automatically run JNLP files, when it is clicked: 1.

Well, that concludes the little 10 minute introduction to running and using the mysql command line client for MAMP in Mac OSX. You can find out much much more about the wonders of mysql by reading the mysql manual.

Mamp Mysql Command Line Not Found

You might also be interested in: