警告:mysqli :: __ construct():(HY000 / 2002):权限被拒绝

时间:2019-04-29 17:42:45

标签: php linux mysqli xampp

起初,我创建的文件上传系统存在问题,因为我没有上传文件的权限(本地主机xampp)。我真的不知道我在linux jet周围的方式,所以我在论坛上读过一些命令chmod和chown,这让我变得更糟。我mysqli无法连接。我希望有人知道我坏了吗?

<?php
    session_start();
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "visitbled";
    $conn = new mysqli($servername, $username, $password, $dbname);
    mysqli_set_charset($conn,"utf8");
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 

?>

我用过的一些命令

sudo chmod +rwx /opt/lampp/htdocs/bled/osnovnideli/
sudo chmod R 0755 /opt/lampp
sudo chown andrej /opt/lampp/htdocs/bled/

错误:

Warning: mysqli::__construct(): (HY000/2002): Permission denied in /opt/lampp/htdocs/bled/osnovnideli/global.php on line 7

Warning: mysqli_set_charset(): Couldn't fetch mysqli in /opt/lampp/htdocs/bled/osnovnideli/global.php on line 8
Connection failed: Permission denied

编辑: 尝试连接数据库时,phpMyAdmin也会发生相同的问题

0 个答案:

没有答案