Basic MySQL PATH question - mysql

In the Terminal prompt, I have to type in $ PATH=/usr/local/mysql/bin:$PATH to run MySQL commands.
Where do I need to save this path in the MySQL files, such that I don't need to type in this path every time I enter into the terminal path. What file, and where should I type this in?
Thank you.
Where can I find the .bashrc file? when I do a cd ~, then ls -a, it does not show up (although I do see a .bash_history.)

You don't have to save $PATH in mysql, you need to save it in your .profile or .bashrc (substitute for your own shell if not Bash) files, found in your home directory.
You have files like these without the dot in frontne in /etc, but they're the system wide ones (they are the default to all users). You should have a file .bashrc or .profile (or you could create them if they don't exist) in your /home/David542 directory (with your own username, of course).
Caveat: depending on your system, you could be using a shell different from bash, so you'd have to create a different dot file (.kshrc, .cshrc, .shrc, etc).

.bashrc in your home directory

Related

How do I specify a path for pyinstaller

I am learning in a tutorial, how to create widgets. The tutorial, however requires you to use pyinstaller to send the program to anyone. The problem I am facing is specifying my path.
Here is a recent attempt on the terminal command:
C:\tkinter.idea>cd pyinstaller.exe --onefile --icon=sun_icon.ico book.py
The system cannot find the path specified.
Comment below if you need further clarification.
The cd command only works for accessing directory files inside your system (folders). As pyinstaller.exe is a program you don't need to pass the cd command, remove this command and just input pyinstaller.exe --onefile --icon=sun_icon.ico book.py in your cmd.

A problem with creating directories in tcl

I am writing a code in tcl using windows. When I try to create a folder using this command
set FileName "GVOutPut";
file mkdir $FileName;
i get this error:
can't create directory "GVOutPut": permission denied
while executing
"file mkdir $FileName"
how could i solve this problem?
You should check that the current directory (puts [pwd]) is the directory where you expect the new directory to be created in instead of being somewhere where normal users can't write by default. It is very easy for that to be different in a GUI program than for a text program; the defaults vary (due to the different ways that they're launched by the OS). It often pays to use full pathnames in your programs, or to make things all relative to a known location. You can use the cd command to set the current directory.
Alternatively, launch the program from an elevated shell. But you probably don't want that option as it has a lot of non-trivial consequences.

PHP Mysql laravel 5.4 terminal issue

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

Specifying separate config file on mysqldump command line

My main MySQL user's /home//my.cnf file looks like this (Linux system):
[client]
host=localhost
user=<user>
password=********
database=h2o_amr
I want to point mysqldump to this config file, which is in the directory where the mysqldump file will be written:
[client]
host=localhost
user=<user>
password=********
How do I point mysqldump to this config file? I have searched for an answer to this in the man pages and the Internet before posting this question.
There are three options to change the default behavior:
--no-defaults: Don't read default options from any option file.
--defaults-file=#: Only read default options from the given file #.
--defaults-extra-file=#: Read this file after the global files are read.
This information was copied from the integrated manual, i.e.mysqldump --help | grep -A7 'Default options'.
Note: The parameter needs to be in first position if you add others parameters, if not it will not be recognized.
According to the documentation, there is a --defaults-file=PATH option that does exactly what you need. I tried it myself with mysqldump and it appears to have worked.
There are also other ways to have MySQL read option files without using that argument: using the default paths MySQL clients search through to compile the list of options (1st and 2nd table).

changing $PATH by editing .bash_profile

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.