Posts Tagged ‘mysql’

How to Change MySQL Data Directory in Linux Centos

Saturday, July 2nd, 2011

By default Linux CentOS or other Linux Distro installation, MySQL data directory is stored in /var/db/mysql, how can I change it to other directory in example /db/mysql?

It is always better to have MySQL Data Directory store in a specific partition/drive. It will help on performance and better management and scalability. You change change the data store directory in Linux by editing /etc/my.cnf file.

Edit /etc/my.cnf file


# vi /etc/my.cnf

Change the data directory structure


datadir=/db/mysql
socket=/db/mysql/mysql.sock

After the file has been updated, restart MySQL service.

How to Install Cacti Plugin Architecture

Tuesday, August 17th, 2010

Cacti Plugin Architecture allow you to run useful monitoring plugins on Cacti. There are several good plugins like Thold, Aggregator and Weathermap which give you comprehensive network device monitoring.

There are a few steps involve In order to install Cacti Plugin Architecture. First we will need to backup current cacti files, and overwrite the files for Cacti Plugin Architecture and lastly to make some changes on configuration files in order to activate Cacti Plugin Architecture.

Installing Cacti Plugin Architecture

Cacti Plugin Architecture can be downloaded at Cacti Users website. The demo I am going to show is to download Cacti Plugin Architecture version 2.8 on Cacti version 0.8.7g.

Before installing Cacti Plugin Architecture, lets make a backup copy of your cacti files, in case something goes wrong, you can roll back to the original files. During the backup, we are going to exclude rra and log directory.

First change directory to the directory which located Cacti files, in FreeBSD would be /usr/local/share


shell> cd /usr/local/share
shell> tar -zcf cacti.backup.tar.gz --exclude=rra --exclude=log cacti

After backup, it’s now safe to replace your cacti files with cacti architecture files. First untar Cacti Plugin Architecture which you have downloaded earlier.


shell> tar -zxf cacti-plugin-0.8.7g-PA-v2.8.tar.gz

After untar-ed cd to plugin architecture folder and edit config.php.dist file with your mysql database credentials. Follow with rename the file to config.php


shell> tar -zxf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
shell> cd cacti-plugin-arch
shell> vi include/config.php.dist
shell> mv include/config.php.dist include/config.php

In include/global.php, edit MySQL database credentials as well.


shell> vi include/global.php

Next, create the database table which required by Plugin Architecture. The file is located at cacti-plugin-arch directory with file name pa.sql.


shell> mysql -u username -p cacti < pa.sql

Now, it's all good, copy all the files into cacti directory. You cacti directory might be different from mine directory path.


shell> cp -rf * /usr/local/share/cacti/

The installation for Cacti Plugin Architecture is done. In order to access to Plugin Setting. Log on to Cacti, go to User Management, click on Admin, check Plugin Management on realm management and Save.

You should see Plugin Management on your left menu bar. On the next post we will go through the plugins for Cacti Plugin Architecture.

Create Root Privilege User on MySQL

Tuesday, May 11th, 2010

By default, MySQL root privileges user is “root”, I always remove “root” userid once I got MySQL installed, mainly for security purpose, secondly I do not want stupid thing happened like someone able to brute force into MySQL database.

You can create “root” alike privilege user in MySQL by following the step below;

  • Access to mysql /usr/local/bin/mysql
  • mysql> GRANT ALL PRIVILEGES ON *.* TO ‘yourusername’@'localhost’ IDENTIFIED BY ‘yourpasswordhere’ WITH GRANT OPTION;
  • mysql> flush privileges;
  • mysql> quit;

You can add a few more privileges user if you have more than 1 person to admin MySQL Database.

Reset MySQL Root Password

Monday, May 10th, 2010

Very often, once we didn’t log on to MySQL database for some time, I guess most of us will forgot the root password. Can we reset the root password? Obviously… Nothing is Impossible :P

Follow the steps below to reset MySQL’s Root Password;

  • Stop MySQL Service
  • Start MySQL Service in Safe Mode: /usr/local/bin/mysqld_safe –skip-grant-tables&
  • Connect to MySQL /usr/local/bin/mysql
  • mysql> use mysql;
  • mysql> UPDATE user set password=password(‘newpassword’) where user=’root’ and host=’localhost’;
  • mysql> flush privileges;
  • mysql> quit;
  • Stop MySQL Service Again
  • Start MySQL Service in normal mode

Log in to MySQL with your newly created password.