Some SQL commands
Create DB table:
create table <Table_name> (<column_name1> , <column_name2> , <column_name3> );
To add a new row:
INSERT INTO <Table_name> (<column_name1>,<column_name2>,<column_name3>,<column_name…>) VALUES(<for_column1>,<for_column2>,<for_column3>,<for_column…>);
update one value or values:
UPDATE <Table_name> SET <column_name_where_update_needed>= WHERE <column_name_where_sql_has to look>=<Value_of_that_column>;
OR
UPDATE <Table_name> SET <column_name_where_update_needed1>= , <column_name_where_update_needed2>= WHERE <column_name_where_sql_has to look>=<Value_of_that_column>;
OR
UPDATE <Table_name> SET <column_name>='”.$PHP.”‘ WHERE name='”.$PHP.”‘” ;
change data type:
ALTER TABLE <Table_name> MODIFY <column_name> ;
convert csv2sql:
load data infile ‘/.csv’ into table <Table_name>
IGNORE 1 LINES #if you want to ignore the first line in csv file
fields terminated by ‘,’ enclosed by ‘”‘ lines terminated by ‘\n’
(<column_name1>,<column_name2>,<column_name3>,<column_name…>);
please note .csv file saved in C://
Reset Cacti admin password
Hello
I will show you how reset Cacti ‘admin’ password
1- Log-in to MySQL as root
[root@centos6 ~]#mysql -p
Enter your MySQL root password
2-Now execute below query to change admin user to the new password (admin)
mysql> update user_auth set password=md5(‘admin’) where username=’admin’;
* new password will be admin
If the previous doesn’t solve the problem please check the below:
A- Check your Disk space and make sure you have free size (/var)
[root@centos6 ~]#df -h
B- Check if the PHP have permissions to add session files.
Thank you
How to know database size in MySQL
Hello
I will show you how to get a databases size in MySQL, this will help you to monitor the increment of database size
1- Log-in to MySQL as root
[root@centos6 ~]#mysql -p
Enter your MySQL root password
2-Now execute below query to get your databases size in MB:
mysql> SELECT table_schema, sum( data_length + index_length ) / 1024 / 1024 “Data Base Size in MB”FROM information_schema.TABLES GROUP BY table_schema ;
* To get your databases size in GB:
mysql> SELECT table_schema, sum( data_length + index_length ) / 1024 / 1024 / 1024 “Data Base Size in GB”FROM information_schema.TABLES GROUP BY table_schema ;
*_* sample of result *_*
+——————–+———————-+
| table_schema | Data Base Size in GB |
+——————–+———————-+
| abouabed | 64.324875531718 |
| information_schema | 0.000003814697 |
| mysql | 0.000528994016 |
+——————–+———————-+
3 rows in set (0.00 sec)
Thank you
How to Setup Local Yum Repository from iso image on CentOS
Hello
In this post we are going to explore how to setup local yum reposeitory, which helps us to install any pakeges without internet access.
1-Check the free space on your server using
[root@FSN-Backup-server 2]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_fsnbackupserver-lv_root
50G 12G 36G 24% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/cciss/c0d0p1 485M 37M 423M 8% /boot
/dev/mapper/vg_fsnbackupserver-lv_home
76G 180M 72G 1% /home
2-Copy Centos ISO image to your server using any transferring application (XFTP)
3-Create mounting point (directory)
[root@centos6 ~]# mkdir /share/CentOS
4-Create localrepo directory in /mnt
[root@centos6 ~]# mkdir /mnt/localrepo
5-Create 1 2 3 directories in /mnt/localrepo
[root@centos6 ~]# mkdir -p /mnt/localrepo/{1,2,3}
6-Mount the ISO from the local file into /mnt/localrepo/1 directory
[root@centos6 ~]# mount -o loop /share/CentOS/CentOS-6.2-x86_64-bin-DVD1.iso /mnt/localrepo/1
7-Make sure the ISO image has been mounted
[root@FSN-Backup-server 2]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_fsnbackupserver-lv_root
50G 12G 36G 25% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/cciss/c0d0p1 485M 37M 423M 8% /boot
/dev/mapper/vg_fsnbackupserver-lv_home
76G 180M 72G 1% /home
/share/CentOS/CentOS-6.2-x86_64-bin-DVD1.iso
4.2G 4.2G 0 100% /mnt/localrepo/1
8-Create Temporary repo folder under /tmp . To put required rpm’s packages for createrepo installation.
[root@centos6 ~]# mkdir /tmp/repo
9-Copy the require pacckages to install create repo
[root@centos6 ~]# cp /mnt/localrepo/1/Packages/createrepo* /tmp/repo
[root@centos6 ~]# cp /mnt/localrepo/1/Packages/deltarpm* /tmp/repo
[root@centos6 ~]# cp /mnt/localrepo/1/Packages/libxml2-python* /tmp/repo
[root@centos6 ~]# cp /mnt/localrepo/1/Packages/python-deltarpm* /tmp/repo
10-Make sure of the copied files
[root@FSN-Backup-server 2]# ls /tmp/repo
createrepo-0.9.8-4.el6.noarch.rpm
deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
libxml2-python-2.7.6-4.el6.x86_64.rpm
python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
11-Install the rpm packages using below command
[root@centos6 ~]# rpm -ivh /tmp/repo/*
Preparing… ########################################### [100%]
1:deltarpm ########################################### [ 25%]
2:python-deltarpm ########################################### [ 50%]
3:libxml2-python ########################################### [ 75%]
4:createrepo ########################################### [100%]
12- Now go to /mnt/localrepo directory
[root@centos6 ~]# cd /mnt/localrepo/
13-Run createrepo command
createrepo .
14-Now check the new directory
[root@centos6 localrepo]# ls
1 2 3 repodata
15-Clean up the repo
[root@centos6 ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning up Everything
Cleaning up list of fastest mirrors
16-Create a repo config file in /etc/yum.repos.d/ directory
[root@centos6 ~]# vi /etc/yum.repos.d/local.repo
17-Insid the repo config file “local.repo” write the below lines
[CentOS6.2-Repository]
name=CentOS6.2 repository
baseurl=file:///mnt/localrepo
enabled=1
gpgcheck=0
18-Last open the current repo file in “/etc/yum.repos.d/CentOS-Base.repo” make sure to disable all tags by changing the (enabled=1;) –To–> (enabled=0;)
How to secure copy SCP
in linux you can copy a file or directory between two different machines using secure copy, as below:
#scp file_name remot_machine_user@remot_machien:/location_in_remote_machine
Example
scp /etc/rsyslog.conf root@10.0.0.2:/etc