MySQL

How to Use Bash Script for MySQL Error Log Rotation

How to Use Bash Script for MySQL Error Log Rotation

Fadıl

We will share with you a script that we can use to find the solution and the solution that we receive in the Mysql database.

Below is the simple script for monitoring MySQL error logs. You can set the cron jobs as per your need(eg. week, daily, hourly)

#!/bin/bash
SERNAME="techsoftcenter"
SERPUBIP="10.0.0.0"
SERVER="ip-10.0.0.0"
 
MAIL_LIST="[email protected]"
Error_log_location=/var/log
Alert_log_path=/opt/work/dblogs
 
sudo egrep -i 'Error' $Error_log_location/mysqld.log |sort -u > $Alert_log_path/mysqld_ALERTLOG.txt
 
if [ $? -eq 0 ]; then
sudo cat $Error_log_location/mysqld.log > $Alert_log_path/mysqld_archived_`date +%Y-%m-%d-%H:%M:%S`.log
 
if [ $? -eq 0 ]; then
 
sudo cat /dev/null > $Error_log_location/mysqld.log
 
else
 
echo "failed to empty file"
 
fi
 
else
 
echo "something went wrong after log file backup"
 
fi
 
cd /tmp/
cd /opt/work/dblogs/
 
FILE_TYPE="*.txt"
FILE_TYPE1="*.log"
 
find ${FILE_TYPE} -type f -mtime +1 -delete
find ${FILE_TYPE1} -type f -mtime +1 -delete
 
if [ -s "$Alert_log_path/mysqld_ALERTLOG.txt" ] ; then
cat $Alert_log_path/mysqld_ALERTLOG.txt | mutt -s "URGENT -ERROR in Mysql Alert Log File for $SERNAME ($SERPUBIP) at `date` " -- ${MAIL_LIST}
fi

Hope it helped.

How To Upgrade  POSTGRESQL 10 To 11

How To Upgrade POSTGRESQL 10 To 11

Fadıl

We will upgrade POSTGRESQL 10 To 11 on CENTOS in this article. Before I begin the redesign procedure, I need to make the accompanying basic cautioning:

You should re-arrange your postgresql.conf and pg_hba.conf records. Since the files will be reset after the redesign.

Install PostgreSQL 11

Postgresql 11 we are installing the following script.

[root@postgres eng]# yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

[root@postgres eng]# yum install postgresql11

[root@postgres eng]# yum install postgresql11-server

initdb

We are performing the initdb task in the Postgresql 11 database.

How to Finding Out Your Server Specs Through A PHP Script

How to Finding Out Your Server Specs Through A PHP Script

Fadıl

Have you ever need to know what your server is running?  Need to see if it runs MySQL?  Well here is a way of knowing what options are available in PHP and what’s going on in your server is to use the phpinfo() function. Create a script with the following.

<html> 
<body> 
<?php 
phpinfo(); 
?> 
</body> 
</html>

Save and view this script through your Web server. You’ll see a page filled with useful and interesting information.  This info tells all about your server, internal Web server environment variables, the options that are compiled, and on and on.
I hope it has been a useful article.

MySQL’s Status Command

MySQL’s Status Command

Fadıl

The status allows you to see various stats on the MySQL daemon. To get to your MySQL shell, type the following command at your shell:

[icezip@saturn ~/]$ mysql -u icezip -p

(where icezip is your user name for MySQL)

A prompt will come up and ask you for your password, so go right in and enter it. This will bring up a MySQL shell.

Welcome to the MySQL monitor.  Commands end with; or g.
Your MySQL connection id is 18724 to server version: 3.22.32
Type ‘help’ for help.

Counting Number Of Entries In A Database

Counting Number Of Entries In A Database

Fadıl

Do you have your own database?  How would you like to know how many entries you have in your database from a PHP page?  Well its easy, I am going to show you a script that will allow you to create a counter that will count the number of entries you have in your database.

Now let’s say we have an email database, and we want to count the number of emails we have in the database.  All we need to do is create this simple script (assuming your database is already made).