如何连接到Hostgator数据库而不是Localhost

时间:2020-09-08 23:45:35

标签: php

我在托管网站上遇到了这个问题。我的问题是,我没有连接到Hostgator的文件管理器,而是连接到了我的电脑,这就是为什么我可以像localhost一样登录到我的网站的原因。我联系了Hostgator,甚至他们也无法解决此问题,因为他们的Web顾问之一对我说了这个:I checked the errors and I could see that the requests are considering the hostname 'localhost' as the URL due to which you are experiencing the issue. You would need to check the script and fix the issue。当我在本地主机中更改凭据时,出现此错误:Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'myHostgatorusername'@'mycomputerip' (using password: YES) in myComputerFileLocation on line 323

我的脚本正确吗?我应该将本地主机更改为类似于站点IP的地址吗?我尝试过,但是对我不起作用。

ConnectDb.php

<?php

namespace Classes;

class ConnectDb
{
    function Connect()
    {
        return new \MysqliDb(array(
            'host' => 'myHostgatorsiteip',
            'username' => 'myHostgatorusername',
            'password' => 'myHostgatorpassword',
            'db' => 'mydatabase',
            'port' => 3306,
            'prefix' => '',
            'charset' => 'utf8'
        ));
    }
}

index.js

 LOGIN (context, payload) {
        return new Promise((resolve, reject) => {
          axios
            .post('http://localhost/MyComposer/', payload, {
              headers: { 'Content-Type': 'application/json' },
              params: {
                submitId: 3
              }
            })
            .then(response => {
              console.log(response.data)

              if (response.data === '') {
                resolve(response)
              }

              for (var i = 0; i < response.data.length; i++) {
                const token = response.data[i].AccessId
                if (
                  response.data.Username === payload.Username &&
                  response.data.Password === payload.Password
                ) {
                  localStorage.setItem('access_token', token)
                  context.commit('accessToken', token)
                  resolve(response)
                }
              }
            })
            .catch(error => {
              reject('Login Error!')
              console.log(error)
            })
        })
      },

0 个答案:

没有答案
相关问题