Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Last active June 4, 2023 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhishekGhosh/d0f8f8defd637afb583be8f5998d8493 to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/d0f8f8defd637afb583be8f5998d8493 to your computer and use it in GitHub Desktop.
Create MySQL Database With PHP
<?php
$servername = "localhost";
$username = "non-root";
$password = "non-root-password";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "CREATE DATABASE ESP32IoT";
if ($conn->query($sql) === TRUE) {
echo "Database has been created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment