简体   繁体   中英

Amazon RDS php integration

I'm kinda new to this database world.
I'm trying to implement some php scripts to be used with Amazon RDS system.
I have already created the RDS db instance, but i'm struggling to connect to the database with php.

To connect:

$link = new mysqli($host, $user, $password, $dbname, $port);

$host is the endpoint provided on the db instance $user and $password are the details i used to create the database.
$dbname , i really don't know where to get this value because on the tags of my database, the database name is empty. $port is 3306 .

When i run the script, this warning comes up:

Warning: mysqli::mysqli(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)~

Can anyone help me please? Thanks.

The database name is the name of the actual database that you created, not the name (tag) of the DB server instance. You had to specify a database name when you created the RDS instance, at the same time you specified the database username and password.

In the RDS console when you are viewing the properties of the database instance there is a field labeled "DB Name". That's your database name.


Also, you'll need to be sure to open the port in the security group assigned to the RDS instance before you will be able to connect.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM