Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Saturday 14 July 2018

Re-Arrange primary key | INDEXING in MYSQL

Re-Arrange primary key | INDEXING in MYSQL
SET @count = 0;
UPDATE `users` SET `users`.`id` = @count:= @count + 1;
Last number of records
ALTER TABLE `jaydipkansagra` auto_increment = 720418;  

Monday 25 December 2017

Export Big sql/mysql database using php file

Export Big sql/mysql database using php file

error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
ini_set('memory_limit', '512M');
$dbinfo = array(
    "host" => 'localhost',
    "user" => 'root',
    "pass" => 'root',
    "dbname" => 'dbname'
);

// Database Config
$sqlhost = $dbinfo["host"];
$dbuser = $dbinfo["user"];
$dbpassword = $dbinfo["pass"];
$dbname = $dbinfo["dbname"];
// filename
$file = date('Ymdhis');
echo shell_exec("mysqldump --add-drop-table -u $dbuser -p$dbpassword`cat /etc/psa/.psa.shadow` $dbname > $file.sql");
//shell_exec("mysql -u $dbuser --password='$dbpassword' --host='$sqlhost' $dbname < $file");
echo 'Finished!<br/>';

Monday 23 January 2017

How to import Big SQL file usign PHP with shell command into hosting server

<?php

error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
ini_set('memory_limit', '512M');

$dbinfo = array(
    "host" => 'localhost',
    "user" => 'magentom_jaydip',
    "pass" => 'rmO22RQ%UbW0',
    "dbname" => 'magentom_jaydip'
);


// Database Config
$sqlhost = $dbinfo["host"];
$dbuser = $dbinfo["user"];
$dbpassword = $dbinfo["pass"];
$dbname = $dbinfo["dbname"];

// filename
$file = "mg_jaydip.sql";

shell_exec("mysql -u $dbuser --password='$dbpassword' --host='$sqlhost' $dbname < $file");

echo 'Finished!<br/>';
?>