Pdo connection without database name?

You can start a PDO connection by this, correct me if I'm wrong:

$db = new PDO("mysql:host=localhost", 'user', 'pass');

The difference from this with a normal connection is the removed part dbname=[xx], as you see.

Also a free tip when you want to use a UTF-8 connection:

$db = new PDO("mysql:host=localhost;charset=utf8mb4", 'user', 'pass');

In order to the comment of Yehonatan you can select a database by:

$db->exec('USE databaseName');

Tags:

Mysql

Php

Pdo