Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

 


Database crash and recovery

1- delete  log files unnecessary in /var/log in order to create free space  that a case preventing mysqld to create mysql.sock file  (find big file size)

2- cd /var/lib/mysql then run " myisamchk *.MYI " to repair all databases

 


24/09/2017

Countries and Continents sql

 
Countries and Continents sql  includes create table and row insertion with iso3 codes

countries.sql
continents.sql


29/12/2015

mssql datetime average

sqlsrv mssql   taking average of datetime column  with groupby select  cast(avg(cast([column1] as float)) as datetime)  from  tablename

14/01/2015

mysql select 1 day ago

SELECT  date_sub(now(),interval 1 day)  from table limit 1    ///   1 day ago SELECT  date_sub(now(),interval 1 week)  from table limit 1  /// 1 week ago SELECT  date_sub(now(),interval 1 month)  from table limit 1  /// 1 month ago

14/01/2015

mysql group every n row

by the way, you can calculate the data like for every  5 minutes ( in database each row  for 20 seconds interval ).   example below : grouped  every  5 row in series as group then you can make function like math avg , count etc. [code] set @i :=0; SELECT *, @i:=@i+1 as rownum, FLOOR(@i/5) AS `datagrp` FROM table_name_muslum21 [/code]

14/01/2015

mysql having count(*) (Miracle )

$$having =" GROUP BY p.ID  having count(*) >=".(count($_REQUEST["DD"])-1)." ";

14/01/2015

GROUP_CONCAT sql function

SELECT GROUP_CONCAT(ProductID) as SomeProductID  FROM Product  WHERE  limitation

 

return is a set of ID   =>   314,34445,234345,24235,252532


14/01/2015