Codeigniter mysqli :: real_connect()错误 [英] Codeigniter mysqli::real_connect() error

查看:3759
本文介绍了Codeigniter mysqli :: real_connect()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上运行的codeigniter应用程序中出现以下错误



遇到PHP错误



严重性:警告



消息:mysqli :: real_connect():( HY000 / 1044):拒绝用户'xxx'@'localhost' '



文件名:mysqli / mysqli_driver.php



行号:161



Backtrace:



文件:/home/arya123/public_html/application/controllers/Home.php
行:7
功能:__construct



文件:/home/arya123/public_html/index.php
行:292
功能:require_once

解决方案

当我将codeigniter项目从localhost上传到Live服务器时,我遇到了同样的错误。



我发现的什么解决方案是对应用程序进行一些更改=> config => database.php



以下是

$的数据库设置b
$ b


localhost




  $ db ['default'] = array(
'dsn'=> '',
'hostname'=> 'localhost',
'username'=> 'root',
'password'=> '',
'database'=> 'creator',
'dbdriver'=> 'mysqli',
'dbprefix'=> '',
'pconnect'=> FALSE,
'db_debug'=> (ENVIRONMENT!=='production'),
'cache_on'=> FALSE,
'cachedir'=> '',
'char_set'=> 'utf8',
'dbcollat​​'=> 'utf8_general_ci',
'swap_pre'=> '',
'encrypt'=> FALSE,
'compress'=> FALSE,
'stricton'=> FALSE,
'failover'=> array(),
'save_queries'=> TRUE
);

以下数据库设置


活动服务器(只是演示,设置因托管服务提供商而异)


1)首先必须创建数据库。



2)在仪表板上查找MySql数据库(或任何相关数据库),



3)创建新数据库put数据库名,用户名,密码。



4)从localhost导出数据库



5)在活动服务器上打开phpmyadmin并导入。 >

6)使用FTP客户端或仪表板更改application => config => database.php的设置。

  $ db ['default'] = array(
'dsn'=>'',
'hostname'=>'mysql.hostingprovider.com',
'username'=>'abc.username',
'password'=>'abc.password',
'database'=>'abc.databasename',
'dbdriver'=>'mysqli',
'dbprefix'=>'',
'pconnect'=> FALSE,
'db_debug'=>(ENVIRONMENT!=='production'),
'cache_on'=> FALSE,
'cachedir'=>'',
'char_set'=>'utf8',
'dbcollat​​'=>'utf8_general_ci',
'swap_pre'=>'',
'encrypt'=&
'compress'=> FALSE,
'stricton'=> FALSE,
'failover'=> array(),
'save_queries'=& b $ b);


I am getting Following error in my codeigniter application which is live on server

A PHP Error was encountered

Severity: Warning

Message: mysqli::real_connect(): (HY000/1044): Access denied for user 'xxx'@'localhost' to database 'xxx'

Filename: mysqli/mysqli_driver.php

Line Number: 161

Backtrace:

File: /home/arya123/public_html/application/controllers/Home.php Line: 7 Function: __construct

File: /home/arya123/public_html/index.php Line: 292 Function: require_once

解决方案

The same error I was getting when I upload my codeigniter project from localhost to Live server.

What solution I find is to make some changes into the application => config => database.php

Following is the database setting for the

localhost

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'creator',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Following database setting for

live server (Just demo, setting differ as per hosting provider)

1) First you have to create database.

2) find MySql Databases(or anything related database) on dashboard,

3) create new database and put database name, username, password.

4) export database from localhost

5) open phpmyadmin on live server and import it.

6) change the setting of application=>config=>database.php by using FTP client or dashboard.

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'mysql.hostingprovider.com',    
    'username' => 'abc.username',
    'password' => 'abc.password',
    'database' => 'abc.databasename',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

这篇关于Codeigniter mysqli :: real_connect()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆