mysql useful commands

Show the binary log files command
 mysql> SHOW BINARY LOGS;    
 +------------------+------------+  
 | Log_name     | File_size |  
 +------------------+------------+  
 | mysql-bin.000001 | 1074232778 |  
 | mysql-bin.000002 | 1073742234 |  
 | mysql-bin.000003 | 1073743283 |  

To delete binary logs ..001 and 002 run below command
 PURGE BINARY LOGS TO 'mysql-bin.000003';



The MariaDB server's binary log is a set of files containing "events" which represent modifications to the contents of a MariaDB database. These events are written in a binary (i.e. non-human-readable) format. The mysqlbinlog utility is used to view these events in plain text.
Example:-
 mysqlbinlog mariadb-bin.000001 > /tmp/mariadb-bin.sql  

 Change user password:  
 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');  
 Grant privileges to user:  
 CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'paSSword123';  
 mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';  
 ls -1   
 mysql-bin.000051  
 mysql-bin.000052  
 mysql-bin.000053  
 mysql-bin.000054  
 mysql-bin.000055  
 mysql-bin.000056  
 mysql-bin.000057  
 mysql-bin.000058  
  for i in `seq 51 58`;do mysqlbinlog mysql-bin.0000${i} > ${i}-log.sql ; sleep 1 ;done   

#Case Insensitive mysql table name

Open terminal and edit /etc/mysql/my.cnf
sudo nano /etc/mysql/my.cnf
Underneath the [mysqld] section.add:
lower_case_table_names = 1

apt error bad sig

Run below commands:-

 aptitude -o Acquire::http::No-Cache=True -o Acquire::BrokenProxy=true update  
 apt-get update  

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 54422A4B98AB5139

find interface upload download bandwidth statistics

parse /proc/net/dev
OR
cat /sys/class/net/eth0/statistics/tx_bytes (or rx_bytes for the number of received bytes)

missing mcrypt php extension

apt-get install php5-mcrypt
php5enmod mcrypt

edit  /etc/php5/apache2/php.ini
 #add below line  
 extension=mcrypt.so  


ls -l  /etc/php5/apache2/conf.d

 20-mcrypt.ini -> ../../mods-available/mcrypt.ini  
 05-opcache.ini -> ../../mods-available/opcache.ini  
 10-pdo.ini -> ../../mods-available/pdo.ini  
 20-gd.ini -> ../../mods-available/gd.ini  
 20-json.ini -> ../../mods-available/json.ini  
 20-mysql.ini -> ../../mods-available/mysql.ini  
 20-mysqli.ini -> ../../mods-available/mysqli.ini  
 20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini  
 20-readline.ini -> ../../mods-available/readline.ini  

restart apache2 with
# service apache2 restart

done