Rename table in MYSQL

MySQL Cluster

  To rename a table in MySQL you just need to run a command named RENAME TABLE, the syntax is very easy to use. RENAME TABLE table1 TO table2; The RENAME TABLE command will rename the table atomically, which means your table will be locked during the command. You can also rename more than one … Read more

mysql get date interval of 30 days

MySQL Cluster

Very often we need to extract last 30 days, 7 days data from mysql DB. Here we will show easy way to get the data of given interval. SELECT DATE_FORMAT(create_date, ‘%m/%d/%Y’) FROM mytable WHERE create_date BETWEEN CURDATE() – INTERVAL 30 DAY AND CURDATE() Also note that CURDATE() returns only the DATE portion of the date, so … Read more

MySQL Interval

MySQL Cluster

MySQL interval values are used mainly for date and time calculations. INTERVAL {value of unit} {types of interval} INTERVAL is a MySQL keyword and this is case sensitive. This should be used in CAPITAL Later Only {value of unit} is a expression or value like 1,2,3,4 or any expression which result in value. {type of … Read more

mysql query get date of 1 month interval

MySQL Cluster

Very often we need to extract last 1 month, 2 months data from mysql DB. Here we will show easy way to get the data of given interval. SELECT * from testtable WHERE startdate BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND DATE_SUB(NOW(), INTERVAL 2 MONTH) The above query will return records whose order date is between one and … Read more

myisamchk — MyISAM Table-Maintenance Utility

MySQL Cluster

The myisamchk utility gets information about your database tables or checks, repairs, or optimizes them. myisamchk works with MyISAM tables (tables that have .MYD and .MYI files for storing data and indexes). The use of myisamchk with partitioned tables is not supported.   How to run this Utility – myisamchk  myisamchk [options] tbl_name The options specify … Read more

MySQL : Introduction to MySQL

MySQL Cluster

Birth Of MySQL MySQL started out with the intention of using the mSQL database system to connect to tables using fast low-level (ISAM) routines. However, after some testing, They conclude that mSQL was not fast enough or flexible enough. This resulted in a new SQL interface to our database but with almost the same API interface … Read more

quickly copy MySQL InnoDB database without using MySQL dump

MySQL Cluster

For this process We should noted that there must have the same architecture on both machines. I.e. if we have 32 bit on one server then other server would also have 32 bit. But in case if we have 32 bit on one server and 64-bit on another then we will have to use MySQL dump. mysqldump – … Read more

mysqli_connect() – function php mysql db connect

MySQL Cluster

The mysqli_connect() function opens a new connection to the MySQL server. Syntax: mysqli_connect(host,username,password,dbname,port,socket); Parameter Description host Specifies a host name or an IP address username Specifies the MySQL username password Specifies the MySQL password dbname Optional. Specifies the default database to be used port Optional. Specifies the port number to attempt to connect to the … Read more

show progress on MySQL DB Import

MySQL Cluster

You can use Pipe Viewer to monitor mysql dump. If you don’t already have pv, you can install it with: yum install pv # pv db1.sql.gz | gunzip | mysql -u root -p db1 693MiB 1:00:33 [ 325kiB/s] [====================> ] 68% ETA 0:16:20