Home > Net >  Raspberry Pi 4 To A Remote MySql: Stderr : /bin/sh: 1: mysql: not found
Raspberry Pi 4 To A Remote MySql: Stderr : /bin/sh: 1: mysql: not found

Time:01-10

In continuation to my previous question here (Fully details: enter image description here

  1. @Mark Setchell suggestions: Here is the terminal response

pi@raspberrypi:~ $ /usr/bin/mysql -u fieldArduinoYUN -h aa.bb.cc.dd -p abcdf -e "use field_data; SELECT product FROM product_list WHERE product_id = 123;"
Enter password:    
ERROR 1044 (42000): Access denied for user 'fieldArduinoYUN'@'%' to database 'abcdf'
pi@raspberrypi:~ $

CodePudding user response:

Summarising the exchanges from the comments, there were the following issues and solutions.


The following error means that the shell (bash/dash/ash etc) was unable to find the mysql command:

/bin/sh: 1: mysql: not found

This normally results from the PATH variable not being set to tell the shell where mysql is located in the filesystem.

It transpired that, in this case, the reason was that the mysql client was not installed. OP had thought that installing a Python module would provide a command-line MySQL client too.

The solution was to install the MYSQL client tools.


The second issue was that the password for the mysql client tool wasn't being provided correctly which resulted in:

ERROR 1044 (42000): Access denied 

This can be solved by providing the password immediately following the -p option and without a space like this:

/usr/bin/mysql -u USER -h aa.bb.cc.dd -pPASSWORD -e "SOMECOMMAND"
  • Related