MySQL service is failing to start up with error “Can’t init databases”
Following is the error message in mysql server log file /var/log/mysqld.log:
/usr/libexec/mysqld: Can’t create/write to file ‘/tmp/ibCfJwf1? (Errcode: 13)
While trying to start it, following is the error.
Initializing MySQL database: [ OK ]
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]
This error occurs when MySQL is not able to access the /tmp directory to write and create temporary files. Make sure /tmp is owned by root and 1777 permisssion is set on /tmp directory.
Following commands will fix the problem.
# chown root:root /tmp
# chmod 777 /tmp
# /etc/init.d/mysqld start
Now MySQL should start without a problem.
Steps to change the mysql database directory in Linux server
Some times the ‘/var’ partition get crowded and we might need to relocate the database to some other location where there is enough space. Below are the steps given for a trouble free relocation.
Note: Let ‘/mysql’ be the directory to which we want to relocate the database.
Steps to change the mysql database directory:
1. Execute the following command in the server to write the transactions saved in the memory to the hard disk.
mysqladmin -u root -p flush-tables
2. Stop the mysql process in the server.
/etc/rc.d/init.d/mysql stop
3. Move the database files to the the new directory.
mv /var/lib/mysql/* /mysql/
4. Create symlink with the old directory.
ln -s /test/mysql /var/lib/mysql/
5. Give the correct ownership to the new directory.
chown -R mysql:mysql /mysql/*
6. Restart mysql in the server.
/etc/rc.d/init.d/mysql start
Taking dump of multiple tables
The mysqldump can be used to dump a database or a collection of databases for backup or for transferring the data to another MySQL server.
Execute the following command to get the dump of a table.
$ mysqldump -uusername -p databasename tablename > dump_filename.sql
This table can be added to the database using the following command.
$ mysql -uusername -p databasename < dump_filename.sql
In order to take dump of N tables named table1, table2.table3….tableN use the following syntax:
$ mysqldump -uusername -p databasename table1 table2 table3 …. tableN > dump_filename.sql
Checking the configuration of named.conf and zone files
The bind package has utilities to check the syntax of named.conf and any zone files. We can make use of those binaries to check our modifications done to those files before reloading or restarting named service.
To check the sytax of zone file /var/named/serverbuddies.com.db
[root@bash ~]# named-checkzone kb.com /var/named/serverbuddies.com.db
zone serverbuddies.com.db/IN: loaded serial 2006032401
OK
If everything is correct, it will show the serial number with which the zone file is loaded. Otherwise, it will give error message indicating the line number at which the error occured.
To check the syntax of named.conf file,
[root@bash ~]# named-checkconf /etc/named.conf
You may also load the configuration of all master zones listed in named.conf at the time of checking the syntax as,
[root@bash ~]# named-checkconf -z /etc/named.conf
The command will show a detailed output in case any error in named.conf file.
This way we can make sure that we are not editing the configuration file wrongly.
Cpanel shows incorrect disk usage
cPanel shows incorrect disk usage
* Disk usage zero for all the domains in ‘list accounts’
* Mismatch between the disk usage in backend and Cpanel
Check whether /home partition has been mounted with ‘usrquota’ option (defaults,usrquota in /etc/fstab)
# cat /etc/fstab| grep home
LABEL=/home /home ext3 defaults,usrquota 1 2
Run the following command.
# quotacheck -c /home
# quotaon /home
Also Check the option WHM >> Server Configuration >> Tweak Settings >> System — Disable Disk Quota display caching