connect to an AWS RDS / MySQL instance from the mysql shell on remotely

connect to an RDS / MySQL instance from the mysql shell on remotely – per the AWS documentation – buried…

mysql -h mysqlinstance1.123456789012.us-east-1.rds.amazonaws.com -P 3306 -u mymasteruser -p
or if the “badboy/mysql” shell is not in your path… you have to add the path…
“C:\Program Files\MySQL\MySQL Shell 1.0\bin\mysqlsh.exe” -h myend-point.us-west-1.rds.amazonaws.com -P 3306 -u clouddb -p
Of course that implies you have the mysql shell installed – if not get it here
https://dev.mysql.com/downloads/shell/
You can also pick up the MySQLWorkBench in the same area…
MySQLWorkBench will generate the php code to connect too – from workbench -> Tools -> Utilities -> Copy As PHP Code – connect strings

$host="mydb.myendpoint.us-west-1.rds.amazonaws.com";
$port=3306;
$socket="";
$user="mydb";
$password="";
$dbname="";
$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
 or die ('Could not connect to the database server' . mysqli_connect_error());
//$con->close();

Note: during this exercise I accidentally left out the DBName when creating the instance. When you do that no custom database is created… the database “innodb” will be there, otherwise just drop the RDS instance and create again with your DB name.
I would suggest if you are creating a WordPress site – that you name your database “wordpress” as that is the default.
MySQL Workbench refers to the database name as “Schema” as if the two were interchangeable – they are not to me but I come from the Oracle Enterprise DB world…
More from LonzoDB on AWS

Leave a Comment

Scroll to Top