Lost connection to MySQL server during query - codeigniter - php

I just made a script in codeigniter which fetches emails and displays them with php imap.
It fetches 500 mails at once no problem.
If i try to fetch about 2000 mails at once, it throws an error.
A Database Error Occurred
Error Number: 2013
Lost connection to MySQL server during query
SELECT GET_LOCK('77dfd862ae2b7bedaec521bc4c3651952b56e6c9', 300) AS
ci_session_lock
Filename: libraries/Session/drivers/Session_database_driver.php
Line Number: 358
This project is live on hostgator. I am not sure if it has mysql workbench or not.
I have no idea where it comes from and why.
I have done nothing with mysql in codeigniter before.
I do not know which file to edit and where to start. Please help.

Related

Using Expression Engine on a local host and getting a database error

I backed up my website and installed it on my local machine using xampp. Well, after creating a database and connecting it, I ran into this error
Error Number: 1146
Table 'mysql.exp_sites' doesn't exist
SELECT * FROM (`exp_sites`) WHERE `site_id` = 1
Filename: C:\xampp\htdocs\website\sitecontrol\codeigniter\system\database\DB_driver.php
Line Number: 330
I have looked into the database and this query exists and also the data. I don't know what to do to resolve it

CodeIgniter Database Error but only one section of app

I have an existing web app but for no apparent reason one section of the app is now displaying the following error:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 338
The rest of the app works fine and can connect using the same database credentials at application/config/database.php
Any help to point me in the right direction in terms of debugging the issue would be welcome.
This is for an existing Linux server, running MySQL 5, PHP 7 and Apache 2.
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 338

CodeIgniter database error when opening the website

The website works fine for a while but in a few days returns this error :
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/2002): Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Filename: mysqli/mysqli_driver.php
Line Number: 202
Backtrace:
File: /var/www/html/application/controllers/Login.php Line: 8
Function: database
File: /var/www/html/index.php Line: 289 Function: require_once
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/CodeIgniter.php
Line Number: 500
Help will be appreciated
Thanks
Nipun
Three things possible. Your database has been shut down (or it has died). You have not setup database to use a unix socket when both client and server are on the same machine. Or socket is not readable and writable by web user.
The warning is being thrown by mysqli driver. I would recommend that you use PDO driver to connect to the Database.It's simpler and a bit universal (You don't need to change Database settings once you change the DB)
you need confirm the database config file:application/config/database.php ensure the confirm item is correct
Please check your mysql server connectivity
If you run the app using your pc name i.e.
sahil-pc/recruitement or http://85.215.963.104:81/recruitement
you need to define it in index.php of root.
please check the permission of your db socket if you are using linux you need to make it in read and write mod.
note: ip details are fake don't try it

CodeIgniter error when connecting to the database

I am trying to uplaod my web to a host, I've had some problems I managed to solve but no this one. It's related to the database, and it only happens sometimes.
In some cases I have to query the database or even for the user registration it works fine, but in other cases I got the error:
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
I debugged the error (thanks #Valeh Hajiyev: CodeIgniter: Unable to connect to your database server using the provided settings Error Message) and in every case the connection seemed to be fine.
I hope someone who has had this problem before could help me.
EDIT: Oh snap! I just found out that refreshing the page a couple of times makes it work. What??

Database update fails when file was uploaded

I have a script where user can attach file to the record. File is stored separately (not in a database). When user does not attach file and click on "Save record" it works fine. When user attaches file it does next steps:
File uploads correct
Script takes from DB record details using Idiorm
Script updates field "filesize" on the record (I tested script without this step - same result)
Script tries to save record, and I get this:
PDOException
Code: HY000
Message: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
File: /home/../includes/idiorm.php
Line: 1675
How can it be solved?
Update:
I found out 2 things:
script returns "General error: 2006 MySQL server has gone away" only when uploaded file is bigger than 20 Mb and I try to update database with Idiorm_record->save().
script does not return "General error: 2006 MySQL server has gone away" when uploaded file is bigger than 20 Mb and I do not try to update database.
I can upload file bigger than 20 Mb and run query generated by Idiorm_record->save() with Idiorm::raw_exec() and catch no error.
Does it mean that problem connected with Idiorm?
The Problem was the "wait timeout" setting in MySQL. But still is interesting why plain sql works fine and update via save method on Idiorm object causes delay that Mysql goes away.

Categories