What would DSN be?

7

Whenever I see someone preparing some database configuration, I see the term DSN appearing.

I see this happening in the parameters of PDO (class to connect to Database) of PHP.

Example:

$dsn = 'mysql:host=localhost; dbname=test';

$pdo = new PDO($dsn);

Is this DSN term some nomenclature used for database? What does this term mean?

    
asked by anonymous 15.12.2016 / 14:47

2 answers

12

DSN is Data Source Name, generically the term defines the settings (ip, user, resource name, port, protocol etc) required for access to a data source. In the case of the question, it is a database. Another example would be LDAP.

    
15.12.2016 / 14:51
4

It is not a nomenclature, DSN is the acronym for Data Source Name (Data Source Name) that contains the information needed to connect to the database. This information can be: the type and name of the database, the user, password, driver, directory, among other information that will be used for the connection.

In documentation you find more explanations and example about it.

    
15.12.2016 / 17:37