I’m using a droplet with Ubuntu 12.04 (32bits) and after installing LAMP into this droplet I cannot access from a php file to my database using the admin user from the site.
I updated my host, username and password to connect but I don’t know If I forgot any command or related tip.
The connection always return not successfull.
I great any notice about this error.
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
When you log in in your server, in the welcome message you can find your mysql password. This password isn’t the same as your ssh user.
-------------------------------------------------------------------------------------
Thank you for using DigitalOcean's LAMP Application.
[...]
Your MySQL root user's password is password here
You are encouraged to run mysql_secure_installation to ready your server for production [...]
How are you trying to connect to the database? Are you catching the error message? That might give you a better idea of what the problem is. Try doing something like:
try {
$conn = new PDO('mysql:host=localhost;port=1234;dbname=$dbname', $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
Many thanks both of you. I didn’t execute the sudo mysql_install_db command into my droplet.
Many thanks all your answers.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.