【问题标题】:What user and password in phpmyadmin will I use in cpanel?我将在 cpanel 中使用 phpmyadmin 中的什么用户和密码?
【发布时间】:2017-11-22 08:53:53
【问题描述】:

这是我第一次上传网站。现在我的主机 CPANEL 出现问题。

我正在使用代码

<?php
date_default_timezone_set("Asia/Manila");

$servername = "localhost";
$username = "root";
$password = "";
$db = "exampledb";


// Create connection
$conn = new mysqli($servername, $username, $password,$db);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

?>

用于我的数据库连接。

现在我的问题是我应该在 servername 中输入什么代码?而不是本地主机? 和用户名root和密码一样吗?

【问题讨论】:

    标签: php mysql cpanel


    【解决方案1】:

    在 cpanel 的托管站点上,他们通常会为您提供您可以使用的服务器名称,您需要在 cpanel 上创建 db 用户的密码,这将是您的用户名和密码。

    【讨论】:

    • 所以你创建了你的数据库,你也可以创建一个数据库用户,这将是你的用户名和密码。
    【解决方案2】:
    // localhost is fine or else you need to keep your server IP.you can find in cpanel.
    $servername = "localhost";
    
    // if you are using database in some other server you should provide IP
    // you need to create a user with required privileges then need to provide username/password 
    // root also fine but better create a user
    $username = "root";
    $password = "";
    
    // Here you need to mention which DB you want use for your application.
    $db = "exampledb";
    

    【讨论】:

    • 可以用域名代替IP吗?
    • 我在访问主机中看到了 IP。那是我需要使用的吗?
    • yes....... 在命令行中检查目的 ping 您的域。您将获得 IP
    • @finwe:我的帖子有什么问题吗?请提及。
    • @Arvin Jason Cabrera
    猜你喜欢
    • 1970-01-01
    • 2016-02-08
    • 2012-07-11
    • 1970-01-01
    • 2013-08-03
    • 2011-10-29
    • 2014-09-18
    • 1970-01-01
    • 2013-10-20
    相关资源
    最近更新 更多