Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find mySQL -- get "command not found" error when trying to access mySQL from command line

I have previously installed, connected and uploaded to a WordPress MySQL database via SSH no problem. The people who run my server made a few configuration changes, and now I get a "bash: mysql: command not found" error when I try to log into MySQL via the command line on the same server to access the same database.

I am relatively new to all of this, so I am really not sure what to do. When I run "which mysql" I get a message that says there is no MySQL executable in the /usr/bin directories. I can verify that MySQL is running between the fact that my site is still live and functioning and when I ran a command to test MySQL, I got a message that said "MySQL works!"

I find MySQL files in several directories, but I'm not really sure what I am looking for and how I connect to it when I do find it. I am also not sure if this is user error, or if somehow someone moved or hid MySQL from me -- likely user error??

like image 718
Samantha Slade Avatar asked Jan 12 '12 03:01

Samantha Slade


3 Answers

A MySQL server is not a MySQL client.

Check if MySQL is running by executing this command:

ps aux | grep mysql | grep -v grep

And install the MySQL client:

sudo apt-get install mysql-client # Or your distribution command
like image 110
Roman Newaza Avatar answered Sep 27 '22 22:09

Roman Newaza


If you have MySQL server up and running on your server, it does not mean you have a MySQL client installed on this server.

Try

ls -l /usr/bin/mysql*

Do you see MySQL binaries exactly present on system?

One more problem: Linux has very strange behaviour when you run binaries for another architecture.

For example, if you run a 32-bit executable on 64-bit system you will get an error message like "command or file not found", even if the binaries are actually present!

like image 43
Alexey Sviridov Avatar answered Sep 27 '22 23:09

Alexey Sviridov


Now mysql-client has changed to default-mysql-client.

Hence the command:

sudo apt-get install default-mysql-client
like image 38
Vivekanand.Bali Avatar answered Sep 28 '22 00:09

Vivekanand.Bali