We have AWS Amazon Linux EC2 instances that connect to separate AWS RDS instances running MySQL.
We want to run the mysql
command on the RDS instances to process a number of large SQL files that contain thousands of SQL statements. However, we need to be able to run these commands from a PHP application installed on the EC2 instances.
Is this possible and how can it be done?
For testing, we installed MySQL on the same machine as the PHP application, and were able to successfully run the mysql
command to query both the localhost MySQL instance as well as the remote MySQL instances on the AWS RDS instances.
However, we're not sure how to do this when MySQL isn't installed and the mysql
command isn't available on the EC2 instances.
We have explored using the ssh
command in combination with the mysql
command, but nothing seems to work yet.
Any advice is greatly appreciated. Thank you.
Even though RDS hosts the mysql
database you still need the appropriate packages to talk to the database such as php-mysql
. In addition, the mysql
package is just the client where mysql-server
would actually install the server service which you don't need when using RDS. You can safely install mysql
and php-mysql
and likely achieve what you are looking for.
For testing, you can install MySQL workbench on the local machine(not on EC2 instance) and configure it to connect to RDS.
https://aws.amazon.com/premiumsupport/knowledge-center/connect-rds-mysql-workbench/
Or, you can also connect to RDS from the command line using command
mysql -h mysql–instance1.123456789012.us-east-1.rds.amazonaws.com --ssl-ca=rds-ca-2015-root.pem -p
For detail explanation of above command visit :- https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToInstance.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.