-bash: mysql: command not found - mysql

I have looked around at other questions that have been posed and they seem to all have the same answer however my issue seems to be unique.
I have installed MySQL to use in an Angular project and have been trying to run mysql -u root -p in order to get things moving but it throws back -bash: mysql: command not found even though I have also done export PATH=${PATH}:/usr/local/mysql/bin inside of my bash_profile.
This seems to be where it ends for a lot of troubleshooting but it seems I have something else wrong. I have tried adjusting the bash profile to where it is just export PATH=${PATH}:/usr/local/mysql just to see if it would work and there wasn't any difference so I changed it back.
My next thought it uninstalling MySQL and reinstalling but I wanted to see if there was a command I am missing.
Thanks for the help!

Turns out all I needed to do was source ~/.bash_profile so it would reload my profile environment.

Related

Phpmyadmin shows blank page

Recently we have upgraded our mysql from 5.5.x to 5.6.x in an Ubuntu 12.04, also we have changed php5-mysql library with php5-mysqlnd(Which is recommended from MySql).
Since our change in library phpmyadmin stopped working and shows a blank page.
I have followed so many forum and advises from forum contributor but have not had success so far.
I also used ubuntu repository as suggested in this other topic at stackoverflow ppa:nijel which I believe has the modified phpmyadmin package and include the support of php5-mysqlnd, but still no success.
I also have enabled highest verbosity on the php.ini but still nor error or warning is generating in any log, using chrome developer tools it shows "500 Internal Server Error".
I am clueless now, if anyone can help me to determine what I may be missing obvious.
I just ran into a very similar error and I thought I would leave my solution here in case anyone finds this searching for my error. The difference was, that phpMyAdmin showed a blank page after a successful login.
The solution was, removing the "X-Frame-Options: Deny" header.
When setting up the webserver, I didn't remember that phpMyAdmin would rely on iFrames to serve its interface.
Check Mysql & Php error log files located at /var/log/mysql/error.log and /var/log/apache2/error.log respectively
Even after multiple uninstall, purge and reinstall of phpmyadmin I did not get a success.
Finally I used bruit-force approach and from another Linux server where phpmyadmin was running properly I copied all i.e. /usr/share/phpmyadmin, /etc/phpmyadmin and /var/lib/phpmyadmin folders and over write them in the problematic server.
Every thing works perfectly now.
Thanks for help Vibhas... I just thuoght to post just for someone's help.
In case someone (like I was) is using phpmyadmin via xampp on windows and has skype turned on - try turning skype off (or configure xampp to use another port).
I was facing a similar issue with phpmyadmin (phpmyadmin was returning a blank page). It was alright once I reinstalled phpmyadmin using:
apt-get install --reinstall phpmyadmin
If you are not root:
sudo apt-get install --reinstall phpmyadmin
When i changed this inside the config.inc.php:
$cfg['UploadDir'] = '/tmp';
$cfg['SaveDir'] = '/tmp';
to:
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
and reloaded the page then it worked directly!
This is a long shot, but it happened to me when I realised after a cPanel password reset I did not check the "Synchronize MySQL password" option.
This used to be defaulted as checked in previous cPanel versions.
To fix all I did was reset my cPanel password again and selected the "Synchronize MySQL password" checkbox and PhpMyAdmin was back.
Hope this helps others, and if its causing a big issue cPanel should select this option by default again.
I had a similar experience after installing mysql 5.5.60 and phpmyadmin 4.2.12 and what did the trick for me was changing folder ownership for /var/lib/php/session which was the solution in another case for getting php-scripts tu run in general. In my case user www-data is trying to execute related scripts, so I set folder permissions accordingly
chown -R www-data:www-data /var/lib/php5/
and the page appeared as expected.
A web search for [phpmyadmin blank page] shows many people are having this problem and there are almost as many different solutions proposed. So let me add one more after spending a day and finally having success:
When the blank page was displaying, I opened Developer Tools (Command-Option-i on Mac in Chrome or Brave). I immediately observed multiple instances of failing to load .js files from phpmyadmin/js/dist. Checking that directory I found that it was indeed empty.
I then went to https://www.phpmyadmin.net/ and downloaded the zip file into a different location. When I unzipped it, I found js/dist did in fact contain many .js files. I copied all of these files to my webserver's phpmyadmin/js/dist directory. And the problem was solved! I now have a working page.
I hope that helps some of you.
Perhaps I should add that I installed phpmyadmin using the Composer install method (% composer create-project phpmyadmin/phpmyadmin). I did it a second time in an offline directory and again the js/dist directory was empty. I don't know if that means I did something wrong or if that install method is broken.

CustomActions before and after RemoveExistingProducts

I am trying to build an msi that will upgrade an installation of mysql.
I can perform the basic upgrade of files and on a clean install everything works fine, the problem I have is, when performing an upgrade I need to perform a couple of actions around the uninstall of the previous version.
The only action I'm having trouble with is a change of one of the MySQL GLOBAL settings using the following command line
mysql.exe -u root --host=127.0.0.1 --port=5002 mysql --execute="SET GLOBAL innodb_fast_shutdown=0"
I do this as it is suggested that when upgrading a database innodb should perform a slow shutdown and this was the easiest way I could see of doing this.
Currently I use the following Wix to perform this action
<CustomAction Id="Innodb_slowshutdown" Property="OLDMYSQLEXE" Execute="immediate"
ExeCommand=""[MYSQLINSTALLBINPATH]mysql.exe" -u root --host=127.0.0.1 --port=5002 mysql --execute="SET GLOBAL innodb_fast_shutdown=0""
Return="check" Impersonate="yes"/>
...
<Custom Action="Innodb_slowshutdown" After="InstallInitialize">UPGRADEFOUND and NOT UPGRADINGPRODUCTCODE and NOT REINSTALL and MYSQLINSTALLBINPATH</Custom>
<RemoveExistingProducts After="Innodb_slowshutdown" />
However this always fails and I cannot understand why as when the fail occurs I copy the exact command line from the msiexec log and run it through a command line.
This works exactly as I would expect but I cannot figure out what the custom action is doing that is different.
During the install a console opens briefly and it would seem that the MySQL executable runs but something is wrong with the arguments and it causes a load of help info to come up, though I cant be sure this is exactly whats happening as it passes very quick.
Is there any way to pause the install at this point so I can see what is in the console?
Can anyone see any obvious problems with my Wix?
EDIT -
Also I'm not sure if this has anything to do with user rights, I run MSIEXEC from a command prompt opened "As Administrator" but if I did need to elevate rights how could I do this when I need to execute the action with the type immediate?
Please note I am aware that Immediate does not allow elevated rights but I cannot use deferred as it will not allow me to execute the command before RemoveExistingProducts.
I am not even sure it is anything to do with rights, I am merely pointing out that I have considered this as a possible reason but I cannot prove it.
Windows Installer doesn't support immediate custom actions that run with elevated rights. To execute a custom action with elevated rights, it must be marked Deferred="yes" and Impersonate="no".
Ok I found my mistake, this was due to not knowing how a Type 50 CaustomAction works.
All I had to do was to use a Property that contained the full path of the executable I wanted to execute and use ONLY command line arguments in the ExecuteCmd property
<CustomAction Id="Innodb_slowshutdown" Property="OLDMYSQLEXE" Execute="immediate"
ExeCommand="-u root --host=127.0.0.1 --port=5002 mysql --execute="SET GLOBAL innodb_fast_shutdown=0""
Return="check" Impersonate="yes"/>

Mysql command line restore error "The system cannot find the file specified."

Ive got a rather strange issue, ive got an automated build tool that is calling through to the mysql command line to teardown then setup a database from an SQL file.
On one computer it is working fine, and its basically calling:
Mysql -h {Connection::Host} -u {Connection::User} --password={Connection::Password} < {sqlFile}
Ive just checked it out on another computer and tried to build and it keeps giving me the error "The system cannot find the file specified.". The MySQL versions are the same 5.1 and no other files have changed. The only thing that i know is different is where the build files are deployed... at home they are deployed to:
d:/code/projects/xxxxx/
whereas on this computer that doesn't work it is deployed to:
c:\Documents and Settings\xxxxxx\My Documents\Projects\Other\xxxxxx\
The interwebs brought back a few possibilities such as the spaces within the path, however ive tried adding the -i to the command (ignore spaces) and it made no difference.
Anyone have any ideas?
It's most likely the spaces in the path. The part after the space will be passed to the program as a different parameter.
Try surrounding {sqlFile} with double quotes.
Mysql .... < "{sqlFile}"

Mac OS X & MAMP - How to run mysql without having to type in the full path?

Right now, if I want to run mysql, I have to do /Applications/MAMP/Library/bin/mysql -u user -ppass... I'd be a happy camper if I could just do mysql -u user -ppass.... Been googling around, but haven't been able to find anything... Have a feeling I'm using dumb search terms, so if anyone here knows how to do this, that'd be awesome...
you can either add /Applications/MAMP/Library/bin/ to your bash PATH variable (edit your .bash_profile, find the line with export PATH=... and add here the path to MAMP bin folder) , or maybe create an alias with alias mysql='/Applications/.../bin/mysql' (also in your .bash_profile).
Add:
export PATH=$PATH:/Applications/MAMP/Library/bin/
to your ~/.profile
It will take effect next time your profile is initialized (I'm not sure when that is under OS X, it might be when you start your terminal application, it might be when you log in)
It depends what shell you're using. You should be able to add /Applications/MAMP/Library/bin/ to your path:
export PATH=${PATH}:/Applications/MAMP/Library/bin
Mac OS uses bash by default. Just add this line to your .bashrc.
Execute . ./.profile to restart your profile.

How to install MySQL on Leopard, Mac OS X 10.5?

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/