I am getting the below error :
[biswas5375@sandbox-host ~]$ mysql
-bash: mysql: command not found
[biswas5375@sandbox-host ~]$ ssh -p 2222 root@localhost
Last login: Fri Jun 22 18:13:17 2018 from 172.17.0.1
[root@sandbox-hdp ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Are you attempting to log into the mysql instance or are you trying to determine if the mysql instance is running or not?
If the former, your access is being denied because you're not supplying the password to the server and so you must invoke the mysql command using the "--password" command line argument and actually supply the relevant password.
If the latter, try using the mysqladmin command instead of the mysql command. mysqladmin is a utility for performing administrative operations:
[root@sandbox-hdp ~]# mysqladmin -u root -p status
If the mysql server is actually running it will return output displaying the uptime, number of running threads, and so on. If the server is not running then it will display an error message indicating that the connection to the server failed.
Instead of trying "[root@sandbox-hdp ~]# mysql -u root" can you also add '-p' option as well in the command line as :
# mysql -u root -p Enter password: hadoop