What are the potential risks of storing password hashes in a MySQL database as char(64) and how can they be mitigated?

Storing password hashes as char(64) in a MySQL database can expose the hashes to potential brute force attacks if the database is compromised. To mitigate this risk, it is recommended to use a stronger hashing algorithm like bcrypt and incorporate a unique salt for each password hash.

// Hash and store password using bcrypt with unique salt
$password = 'password123';
$salt = uniqid(mt_rand(), true);
$hashed_password = password_hash($password . $salt, PASSWORD_BCRYPT);

// Store hashed password and salt in database
$stmt = $pdo->prepare("INSERT INTO users (username, password_hash, salt) VALUES (:username, :password_hash, :salt)");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':password_hash', $hashed_password);
$stmt->bindParam(':salt', $salt);
$stmt->execute();