skip to Main Content

I have created a virtual machine hosting a WordPress website and an Azure Database for MySQL.

Sample credentials:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wpuser');
define('DB_PASSWORD', 'my_password');
define('DB_HOST', 'dev-mysqldb-sophal.mysql.database.azure.com');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

For testing purposes, I have allowed all IPs to connect to the database and disabled the require_secure_transport parameter.

I can connect to the database with MySQL client using the same credentials. I also managed to create a table using the following script:

<?php
$servername = 'dev-mysqldb-sophal.mysql.database.azure.com';
$database = 'wordpress';
$username = 'wpuser';
$password = 'my_password';

$link = mysqli_connect($servername, $username, $password, $database);

if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

// sql to create table
$sql = "CREATE TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";

if ($link->query($sql) === TRUE) {
  echo "Table MyGuests created successfully";
} else {
  echo "Error creating table: " . $conn->error;
}

mysqli_close($link);
?>

2

Answers


  1. first think you have to go into your database and create a new database
    then go to the file wp-config.php and delete it because you don’t need to modify anything inside it WordPress gonna take the file wp-config-sample.php and it will generate all what you need in the best way from the graphic interface you need just to enter the database name and the password for the database and your user name and your password
    and after that it will generate automatically wp-config.php with the all content you need

    Login or Signup to reply.
  2. Try this :

    1. Create manually your database "wordpress" in Azure Database for MySQL

    2. In your wp-config.php on your VM, put this :

    • (‘DB_NAME’, ‘wordpress’);
    • (‘DB_USER’, ‘wpuser’);
    • (‘DB_PASSWORD’, ‘my_password’);
    • (‘DB_HOST’, ‘dev-mysqldb-sophal.mysql.database.azure.com’);
    • (‘DB_CHARSET’, ‘utf8’);
    • (‘DB_COLLATE’, ”);

    Hope this helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search