Connection Error

Hello admin,
My username is epiz_26135800.
my web name is aungmyatmoe.epizy.com.
I test my web to create database by coding codes below.

<?php

$servername = "sql310.epizy.com";

$username = "epiz_26135800";

$password = "HIDDEN BY MOD";

// Create connection

$conn = new mysqli($servername, $username, $password);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}

// Create database

$sql = "CREATE DATABASE myDB";

if ($conn->query($sql) === TRUE) {

echo "Database created successfully";

} else {

echo "Error creating database: " . $conn->error;

}

$conn->close();

?>

I test for my dynamic website.But not connect.Return error below.

Connection failed: Access denied for user ‘epiz_26135800’@‘192.168.0.47’ (using password: YES)

What should I do.

Create database from PHPMYADMIN on cpanel, you cannot create it using php.

4 Likes

Basically what @anon19508339 said. Except for the fact that databases are created through the MySQL Databases section in the control panel, not phpMyAdmin.

Creating databases in phpMyAdmin requires either permissions to be setup beforehand, or administrative privileges. Since the database servers are shared among users, you don’t get root powers. So on any system where you don’t have the full database server, you’ll need to use the tools provided by the database operator to create the database schemas.

7 Likes

Thank you!

I suddenly wrote Phpmyadmin and you replied before i edit.
Btw thank you for letting me know.

3 Likes

I creatt database named as test.But not connect to MySQL.
Error message is also same as access denied .What should I do.

After that you can use this code to connect to your database:

<?php
$servername = "sql310.byetcluster.com";
$username = "epiz_26135800";
$password = "********";
$dbname = "epiz_26135800_test";

$db = mysqli_connect($servername, $username, $password, $dbname);
if(!$db) echo "Connection failed: ".mysqli_connect_error();

replacing the asterisks with your hosting account password.

6 Likes

Please note that if you create a database schema with the name test, the full database name with be epiz_26135800_test. Database names are always prefixed with your account username. If you omit the username from the database name, you’ll also get an access denied error.

4 Likes

thank ypu so much for ansowing to me.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.