6
votes

I try to connect to my RDS MySQL instance from an SSH connection to my ec2 server (through PUTTY) as outlined here: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToInstance.html#USER_ConnectToInstance.CLI

But I get:

-bash: mysql: command not found

I think maybe I have to install the MySQL Utility client on my ec2 linux server? If this is the case how do I do this?

I try to run the mysql command from my /home/ec2-user directory.

5
I expect a lot of programmers are given the task of getting a web-server going, so I understand why this was posted here; still, this question probably should have been posted on serverfault.comtimeSmith

5 Answers

9
votes

When using Amazon Linux 2 AMI, we need to install mysql. Use this command to install mysql on the instance:

sudo yum install mysql

And then you can connect using this command:

mysql -h change-to-your-rds-endpoint.rds.amazonaws.com -u <USER> -p
4
votes

First install mysql into your ec2 instace using below command sudo apt-get install mysql-server mysql-client

After installing mysql try with below cmd to connect RDS

mysql -h hostname -u username - p password

4
votes

Install mysql client on AWS Linux EC2:
$ sudo yum install mysql

Connect:
$ mysql -h endpoint -P port -u masteruser -p

If you enter your password and nothing happens, check your security groups. You may need to edit your inbound rules.

2
votes

You'll need to install MySQL. Amazon AMIs use yum instead of apt so use:

sudo yum install mysql-server mysql-client

if you are working to setup a LAMP (Linux, Apache, MySQL, PHP) server then follow these instructions http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html

0
votes

Install the mysql client lib with the package manager of your system, for example on Ubuntu:

apt-get install mysqlclient