I am trying to add a path so I don't have to keep typing usr/local/mysql/bin every time I want to start Mysql. I found instructions here that say:
Edit the file /etc/profile and update the path by adding:
usr/local/mysql/bin/, for example:
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/mysql/bin"
Problems:
1. There is no existing line in my profile file that says 'path'. This is what it currently says in profile:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval '/usr/libexec/path_helper -s'
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
2. I really have no idea what I'm doing on a mac (yet). What do I add/change to the above file so mysql is easier to access?
It depends on whether or not you want all user accounts to have access to MySQL, or just you.
For everyone, edit /etc/profile as instructed and add the following to the end:
export PATH=$PATH:usr/local/mysql/bin
For just you (ALSO, this is safest so you don't accidentally mess up any system variables!):
Get a terminal session: Launch Terminal if it's not already running.
Make sure you're in your home directory:
CD ~
See if .bash_profile exists:
ls -al .b*
If it does, open it with your favorite text editor. If it doesn't, launch your favorite text editor and Save as... .bash_profile in your home folder.
Add this line to .bash_profile and Save:
export PATH=$PATH:/usr/local/mysql/bin
Then close Terminal and open again for the change to take effect.
Hope this works out for you.
Related
During the work, there are a lot of partners in the project, and sometimes I need to switch among different partners a lot, and every time the process:
change the partner name in .env file manually
run docker-compose down in the terminal
run docker-compose up -d in the terminal
run gulp dev --partner <partner name> in the terminal
So my question is :
Would it possible to use one line of command to complete the entire above process (such as in the package.json, "docker": "docker-compose down && docker-compose up -d", then npm run docker means running docker down and up)
Basically the main point should be :
Would it be possible to use command line to open, edit and save a file? (I know I could use command line to open vi, and then to edit inside vi, but here is not the case)
There's certainly methods of text editing from the command line (see sed/awk etc.) My solution to this, would be to have multiple .env files:
e.g. .env.alice; .env.bob; .env.charlie
Then as part of my script I would symbolically link the one I wanted:
ln -sf .env.alice .env
The rest as you described.
How to open a project in PhpStorm from command line on Windows?
I tired this:
How to open a directory in PHPStorm or IntelliJ (or any JetBrains IDE) from the command line? but can't find Tools -> Create command line launcher on Windows.
I am using latest PhpStorm.
To open the current directory just run:
phpstorm64 .
If you are using git bash on Windows run:
cmd "/C phpstorm64 ."
Make sure that C:\Program Files\JetBrains\PhpStorm 2018.3.3\bin is in your environment variable PATH (it is by default after the installation)
Edit 2021:
Install Jetbrains Toolbox
Go to settings
Enable "Shell Scripts" and follow the instructions
Now you can use "phpstorm ." to open the current directory.
On macOS ( I assume on windows too) there is option to "Create Command-line Launcher". Just click that and you are good to go next time you open a terminal.
You can even specify how you would like to start "pstorm" / "phpstorm" / "ps" etc.. up to you.
Command-line launcher is currently only available fo UNIX; there is a feature request for providing it on Windows, IDEA-114307, please feel free to vote for it.
If you like to start PhpStorm from command prompt, open cmd console, cd to %PS_install_dir%/bin and run either phpstorm64.exe or phpstorm.bat, passing a path to project folder to it, like it's described in https://www.jetbrains.com/help/phpstorm/opening-files-from-command-line.html. If you like to start it from any directory, add %PS_install_dir%/bin to your system %PATH%
I know this is too late, but it will help others if they need it:
if you want to open phpStorm in the current directory via cmd/Powershell, just use this command:
phpstorm64.exe .
Or if you want to open it in another directory, just use:
phpstorm64.exe YOUR_DIRECTORY_PATH
as simple as that!
go to your project using terminal
Cd myproject
and write
phpstorm64.exe
then hit enter
I see this is a little old but I wanted to supply my answer as I was grappling with this yesterday. My solution was to use cygwin.
Track down the phpstorm bin folder called something like C:\Users\UserName\AppData\Local\JetBrains\Toolbox\apps\PhpStorm\ch-0\201.7223.96\bin and add it to your windows system Path environment variable.
Next fire up a cygwin terminal and navigate into your project directory. I'm not a bash expert so I struggled to sort out the code as an alias but if you run:
crntproj=$(cygpath -w $PWD)
phpstorm.bat $crntproj
You need cygpath because simply running phpstorm.bat $PWD doesn't work as PHPStorm tries to open a folder called $PWD. I tried a bunch of variations trying to get it to open and none seemed to work.
It will fire up phpstorm with the current folder as the project path. And you now have a terminal feed from your project too.
i am new to laravel i just figured out how to install composer laravel etc etc on my local machine MAMP on windows , Now i am confuse with the command on terminal which is
C:\project>mysql -uroot -proot
'mysql' is not recognized as an internal or external command,
operable program or batch file.
How can i fix this ?
setting Environment will solve the issue
Go to Control Panel -> System -> Advanced
Click - Environment Variables
Go to- System Variables find PATH and click on it.
add the path to your mysql\bin folder to the end paths. (ex: E:\xampp\mysql\bin) and add ; end of the line
Close all the command prompts you opens.
Re open and try it.
Setting the PATH to point to the MYSQL bin folder is normally the first thought, but I find that dangerous as things get left lying around when you change software.
I normally create a little batch file in the projects folder or in a folder that it already on your PATH, like this
mysqlpath.cmd
echo off
PATH=C:\mamp\path\to\the\mysql\bin;%PATH%
mysql -v
The mysql -v will output the mysql version number but it is a handy way of knowing that the correct folder has been added to the PATH. This adds the folder to the PATH but only for the life of the command window.
Then just run this from any command window when you want to use MYSQL from the command line
> phppath
You may also like to create one for PHP as well
phppath.cmd
echo off
PATH=C:\mamp\path\to\the\php\;%PATH%
php -v
I am having some trouble changing my $PATH variable to include my recent mysql install. This is what I did. In a terminal session (using the zsh shell) I typed
nano .bash_profile
Inside of this file I put
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
I exit, save, and when I type
cat .bash_profile
I can see the file was edited properly but when I close the terminal session, open a new window, and type
echo $PATH
I get the following:
/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin
So not only is my new mysql path not in there but it didn't change at all. It must be saved in a different file besides .bash_profile correct? Any ideas which one?
Thanks in advance
The correct way to add paths to the environment in OS X is to create entries in /etc/paths.d, so in this case you might put "/usr/local/mysql/bin" into /etc/paths.d/mysql. More info in this question.
You can add:
export PATH="/usr/local/mysql/bin:$PATH"
into your .bash_profile file and you need to RESTART the terminal
or open new tab to check the added path.
I followed this tutorial to the very end, then found out it didn't work right. I think I have everything installed but when I type
mysql -uroot
I only get
-bash: mysql: command not found
Note: I did not skip the "Setting the Path" step. Upon running this command for the first time:
mate ~/.bash_login
This brought up an empty file. So I added this line:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
I saved the file, closed TextMate, executed the following command:
. ~/.bash_login
...and continued with the tutorial. Based on your suggestions, I thought maybe the file didn't actually get saved. So I ran the following command to bring up the file again:
mate ~/.bash_login
...yet the contents of the file were as they should be.
Any suggestions?
You probably don't have the mysql binaries in your path.
The link you posted has a section on setting the path, titled "Setting the Path Do not skip this step! Most everything else will fail if you do."
EDIT: As debugging steps, try:
First launching a new terminal window. Does it run now?
Typing "echo $PATH" at the prompt. Does the path show up correctly as you've typed it in bash_profile?
Running it the long way: /usr/local/mysql/bin/mysql -u root
Does the application run?
Did you follow the step that says
Setting the Path
Do not skip this step! Most everything
else will fail if you do.
Did you close your terminal window and re-open it afterwards?
Update:
What does "which mysql" say? Does "ls /usr/local/mysql/bin" say?
Two things:
Try editing ~/.profile (rather than ~/.bash_profile or ~/.bash_login).
You may find it easier to use the native Mac style .dmg installer directly from Sun.
One nice thing about the dmg installer is that it automagically sets up symlinks to /usr/local/mysql (which means less - or no - fiddling with your $PATH).
Another option would be to use MAMP.
It has Apache, PHP and MySQL packaged with no further setup necessary.
MySQL is usually put in /usr/local/mysql/bin/
You need to add this to your PATH, you can do this by adding the follwoing lines to your .bash_profile
PATH=$PATH:/usr/local/mysql/bin/
export PATH
The .bash_profile file is located in the root of your username directory.
Make sure you restart your Terminal for the setting to take affect.
And if you're not a command-line person, I highly recommend you also install the MySQL Preference Pane to start/stop the server and install Sequel Pro to create databases and run queries.
ftp://ftp.mysql.com/pub/mysql/download/gui-tools/MySQL.prefPane-leopardfix.zip
http://www.sequelpro.com/