Jump to content
Larry Ullman's Book Forums

Recommended Posts

Does anyone know if you have to actually keep going to the directory when in terminal: 

 

/Applications/MAMP/Library/bin/mysql

 

or

 

Can you simply just write MySQL in the Terminal for connecting to MySQL database in order to start reading, writing, and creating records, tables, and databases in MySQL? 

 

Is there a work around with this? What am I missing? 

 

Thanks

 

Lance 

Link to comment
Share on other sites

If you are on Linux/Unix (OSX) ignore this. If you are on windows, you should get a command line tool like Git Bash. It'll follow along if you ever download GitHub for Windows or download "msysgit". Git Bash is close to regular Linux/Unix syntax, so the syntax should work for all operating systems moving forward.

 

With that done (or ignored), you want to create a .bashrc inside your users/%username% folder. That is the same folder on both Mac and Windows to my knowledge. Not sure about Linux. (But I would guess so) There create a .bashrc file (notice the leading dot) and open it with any editor. Notepad/Vim/Nano/Etc. Replace the user with your own.

$ cd c:/users/thomas/
$ touch .bashrc
$ notepad .bashrc

Inside that file, you'll need to somthing called an alias:

alias mysql="D:/xampp/mysql/bin/mysql.exe"

# Recommend to add this too
# Defines a shortcut ls handle to view hidden files, etc.
alias ls="ls -laG"

Here, I've defined that 'mysql' is an aliases for the full path to the MySQL executable. This is likely a little different for you, and is based on XAMPP MySQL here. The same principle is true for Mamp though. Consider doing the same for PHP, composer and any other good stuff you might have.

 

Save the file, restart the terminal (it won't be available otherwise) and there you go. :)

 

Just ask if you have any questions.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...