Hướng dẫn php mysqli query timeout

1. Mục đích:
Bài viết này sẽ hướng dẫn cho quý khách xử lý lỗi timeout khi import các file database có dung lượng lớn (>50MB).

2. Nguyên nhân:

Theo cấu hình mặc định của các máy chủ quý khách hàng chỉ có thể được phép upload tối đa file database (.sql, .sql.zip) là 50Mb khi thực hiện việc Upload và Import database từ giao diện PhpMyAdmin.  Việc import một lượng lớn dữ liệu vào mySql sẽ mất khá nhiều thời gian thực thi của php. Trong khi mặc định phpMyAdmin chỉ cho phép file php thực thi trong 300 giây, nếu thời gian thực thi lớn hơn sẽ gây ra lỗi timeout.

3. Cách xử lý:
 Đối với máy chủ có License cPanel

Nếu quý khách có sử dụng License Cpanel quý khách có thể thực thiện thao tác sau để kiểm tra việc cấu hình cho phép upload của máy chủ.

  1. Đăng nhập vào giao diện WHM/cPanel.
  2. Tìm đến menu Service Configuration » PHP Configuration Editor
  3. Tại đây quý khách cần tìm tham số max_execution_time và tăng tham số này lên.  Đây là tham số quy định thời gian thực thi php. Đơn vị tính là giây(s). Nếu quý khách đặt là 0 có nghĩa là không giới hạn thời gian thực thi. Sau đó Save lại.

Hướng dẫn php mysqli query timeout

 Đối với máy chủ không có License cPanel

Nếu không sử dụng License cPanel, thao tác sẽ khó khăn hơn một chút, khi đó quý khách phải chỉnh sửa trên file php.ini.

      1. SSH vào server cần cấu hình.

      2. Tìm file php.ini

      Tuỳ vào cấu hình trên từng server khác nhau nên file php.ini có thể nằm ở đường dẫn khác nhau. Quý khách có thể sử dụng lệnh sau để tìm file php.ini 

      # find /usr -name php.ini 

       Lệnh trên sẽ trả về danh sách các đường dẫn có file php.ini

       3. Mở file php.in tìm và thay đổi tham số

       max_execution_time = 300  (hoặc lớn hơn)

       Sau đó Save lại.
4. Hướng dẫn import database trực tiếp bằng Command line.
Các bước để import database bằng lệnh như sau:
    1. Upload file dumpfilename.sql  lên server. Khách hàng có thể dùng FTP để upload. (tham khảo tại đây.)

    2. Tạo database 

        CREATE DATABASE database_name;

     Sau đó tạo user và gán quyền cho user (tham khảo tại đây)
    3. Dùng lệnh sau để import database.

   mysql -u [username] -p [database_name] < [dumpfilename.sql]
Với:
username là user dùng để chạy database.
database_name là tên database cần import.
dumpfilename.sql là file database vừa upload lên server.

Ngoài ra quý khách có thể tham khảo thêm bài viết hướng dẫn sử dụng bigdump để import dữ liệu có dung lượng lớn tại đây

Hướng dẫn php mysqli query timeout

How to play audio file in php

please tell me how to play a sound file(.wav) using php script. I need to get the values from DB and Depending upon the values i should play a sound file. thanks in advance.iam using linux operating ...

Hướng dẫn php mysqli query timeout

Hướng dẫn dùng c getcwd trong PHP

Hàm này lấy thư mục đang làm việc hiện tại.Trả về thư mục đang làm việc hiện tại nếu thành công, hoặc FALSE nếu thất bại.Lưu chương trình trên trong ...

Hướng dẫn php mysqli query timeout

Hướng dẫn mysql_real_escape_string in pdo

What are the basic syntax of php?A PHP script is executed on the server, and the plain HTML result is sent back to the browser.Basic PHP SyntaxA PHP script can be placed anywhere in the document.A ...

Hướng dẫn php mysqli query timeout

How do i print a php script?

With PHP, there are two basic ways to get output: echo and print.In this tutorial we use echo or print in almost every example. So, this chapter contains a little more info about those two output ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php sha256 decrypt

Như Johannes Gorset đã chỉ ra, bài đăng của Thomas Ptacek từ Matasano Security giải thích tại sao các hàm băm đơn giản, đa năng như MD5, SHA1, SHA256 và SHA512 là những ...

Hướng dẫn php mysqli query timeout

Php built in functions list with examples pdf

What is a Function in PHP?A Function in PHP is a reusable piece or block of code that performs a specific action. It takes input from the user in the form of parameters, performs certain actions, and ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php create process

(PHP 4, PHP 5, PHP 7, PHP 8)getmypid — Gets PHPs process IDDescriptiongetmypid(): int|falseParametersThis function has no parameters.Return Values Returns the current PHP process ID, or false on ...

Hướng dẫn php mysqli query timeout

Install php gd extension windows

Issue was resolved. I am using XAPP.I tried to search for extension=php_gd2.dll file in php.ini file but there was no such thing there (;extension=php_gd2.dll was also not there with a ...

Hướng dẫn php mysqli query timeout

Hướng dẫn dùng hello echo trong PHP

Lệnh Echo trong PHP là một lệnh của ngôn ngữ lập trình PHP, không phải là một hàm, do đó bạn không cần phải sử dụng dấu ngoặc đơn với nó. Nhưng nếu ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php regex quantifiers

POSIX Regular Expression trong PHPCác dấu ngoặc vuôngQuantifier trong PHPVí dụDãy ký tự được định nghĩa trước trong PHPHàm tích hợp Regexp POSIX trong PHPPERL-style ...

Hướng dẫn php mysqli query timeout

Can i use phpmyadmin with mysql?

Introduction¶ phpMyAdmin is a popular web-based administration tool used to administrate MySQL servers and databases. This tutorial illustrates how to create a new database and a new user to access ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php mysqli query timeout

Hướng dẫn php mysqli query timeout

Hướng dẫn php mongodbclient

Bài viết được sự cho phép của smartjob.vnMongoDB hỗ trợ rất nhiều Driver cho các ngôn ngữ lập trình khác nhau. Trong bài viết này, SmartJob trình bày về việc ...

Hướng dẫn php mysqli query timeout

E billing and invoice system project in php

Subscribe us on YouTube for latest updateA fully working project based on an Online Invoice Management System that is written in PHP and runs on MySQL. The PHP project below has all of the necessary ...

Hướng dẫn php mysqli query timeout

Build furniture e commerce website using php

eCommerce-Furniture-websiteeCommerce website using PHP and frontend programming languages. This is an eCommerce website (Furniture shop) made using PHP, HTML, CSS, Javascript, Jquery as the main ...

Hướng dẫn php mysqli query timeout

Php code showing instead of running xampp

Asked 9 years, 11 months agoViewed 51k times Possible Duplicate: PHP code is not being executed (i can see it on source code of page) web browser not processing PHP code as PHP codeI have installed ...

Hướng dẫn php mysqli query timeout

What is an interface in php?

PHP - What are Interfaces?Interfaces allow you to specify what methods a class should implement.Interfaces make it easy to use a variety of different classes in the same way. When one or more classes ...

Hướng dẫn php mysqli query timeout

Hướng dẫn object htmlinputelement php

Add object to list pythonTo add a single element to a list in Python at the end, you can simply use the append() method. It accepts one object and adds that object to the end of the list on which it ...

Hướng dẫn php mysqli query timeout

Is null or null mysql?

What is a NULL Value?A field with a NULL value is a field with no value.If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php 8 on iis

Bài viết này sẽ hướng dẫn bạn Hệ Thống IIS Cơ Bản (Windows + IIS + PHP + MYSQL+ SSL free Let’s Encrypt). Nếu bạn cần hỗ trợ, xin vui lòng liên ...

Hướng dẫn php mysqli query timeout

Hướng dẫn dùng passthr trong PHP

Như được rút ra từ http://php.net/ && Chipmunkninja :Các hệ thống () Chức năngHàm hệ thống trong PHP lấy một đối số chuỗi với lệnh để thực thi cũng ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php-fpm port

Does my mac have php?Change language:Submit a Pull Request Report a Bug Table of ContentsUsing PackagesUsing the bundled PHP prior to macOS MontereyCompiling PHP on macOS This section contains notes ...

Hướng dẫn php mysqli query timeout

Postgresql import data from excel

As explained here http://www.postgresonline.com/journal/categories/journal/archives/339-OGR-foreign-data-wrapper-on-Windows-first-taste.htmlWith ogr_fdw module, its possible to open the excel sheet ...

Hướng dẫn php mysqli query timeout

Hướng dẫn array to xml, php

Most of the above answers are correct. However, I came up with this answer which solves the array_walk_recursive compatibility issue and also the numerical keys problem. It also passed all the tests ...

Hướng dẫn php mysqli query timeout

Docker php ext install pdo_sqlsrv

I have a simple docker file, as follows:FROM php:7.2-apache COPY src/ /var/www/html/ Normally to install drivers for Mongo or MySQL connectivity I would do so by adding something like the below to ...

Hướng dẫn php mysqli query timeout

Check mysql version in workbench

In this tutorial I will explain how to check MySQL version number in different ways. MySQL provides some features for particular version numbers and on particular platforms only. So, in some ...

Hướng dẫn php mysqli query timeout

Hướng dẫn scrolling calendar html

Calendar hay dịch sang tiếng việt là lịch, một trong những thứ không thể thiếu trong đời sống hằng ngày của mỗi chúng ta. Tuy nhiên thì hiện nay không nhiều ...

Hướng dẫn php mysqli query timeout

Hướng dẫn dùng xml decode trong PHP

Mã hóa chuỗi unicodeTrường hợp bạn cần viết một chuỗi unicode được mã hóa mà không được sử dụng trực tiếp ký tự unicode vào code. Cách này đặc biệt ...

Hướng dẫn php mysqli query timeout

Explain flow structure in php

Today, were going to discuss control structures and loops in PHP. Ill show you how to use all the main control structures that are supported in PHP, like if, else, for, foreach, while, and ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php control structures

Tác giả: Dương Nguyễn Phú CườngNgày đăng: Hồi xưa đóWhat is a control structure? Code execution can be grouped into categories as shown below Sequential – this one involves ...

Hướng dẫn php mysqli query timeout

Hướng dẫn date_format trong mysql

Trong bài này mình sẽ hướng dẫn cách sử dụng hàm DATE_FORMAT trong MySQL thông qua cú pháp và ví dụ thực tế.Bài viết này được đăng tại ...

Hướng dẫn php mysqli query timeout

Hướng dẫn change charset mysql

from utf8 to utf8mb4:1.show all DATABASE default characterset:SELECT SCHEMA_NAME YOUR_DATABASE_NAME, default_character_set_name charset, DEFAULT_COLLATION_NAME collation FROM ...

Hướng dẫn php mysqli query timeout

How mysql password is encrypted?

Many encryption and compression functions return strings for which the result might contain arbitrary byte values. If you want to store these results, use a column with a VARBINARY or BLOB binary ...

Hướng dẫn php mysqli query timeout

Hướng dẫn dùng fetchall php trong PHP

Sử dụng pdo trong php trong php bài bài viết hướng dẫn bạn cách dùng thư viên PDO của php để thao tác với dữ liệu trong database.Nội dung chính2. Kết nối đến ...

Hướng dẫn php mysqli query timeout

What is simplexml in php?

IntroductionInstalling/ConfiguringRequirementsInstallationRuntime ConfigurationResource TypesPredefined ConstantsExamplesBasic SimpleXML usageDealing with XML errorsSimpleXMLElement — The ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php mysqli query timeout

What is isset ($_ post in php?

Trying to understand what this isset($_POST) code is doingif (isset($_POST[Submit])) { $title=$_POST[title]; $forename = $_POST[forename]; $surname=$_POST[surname]; ...

Hướng dẫn php mysqli query timeout

Hướng dẫn install nodejs docker

Mở đầuNgày nay, việc phát triển web có rất nhiều lựa chọn, không còn gói gọn trong những stack lâu đời như LAMP, Ruby on Rails ... nữa. Đặc biệt nổi lên ...

Hướng dẫn php mysqli query timeout

Hướng dẫn php security vulnerabilities

At Privacy Australia, we look at all the privacy services on the market today, and review each and every one of them. We’ll review the best, the worst, and everything in between, taking a look at ...