MyTrueHost launched Web Hosting for Indian clients just in Rs 60/Month with various payment options(netbanking, debit card, credit card,cash card or paypal).
Please Visit at https://www.mytruehost.in

How to change the storage engine to InnoDB

1.Edit the /etc/my.cnf file and look for this line:

skip-innodb

and comment it out:

#skip-innodb

2.Add the following entry in the /etc/my.cnf file

default-storage_engine = InnoDB

3. Save the file, and restart mysql

/etc/rc.d/init.d/mysqld restart

4. You can use the following command to check the “storage engine” used in the server.

mysqladmin variables | grep storage_engine

You will see the storage engine as “InnoDB”.

# mysqladmin variables | grep storage_engine
| storage_engine                  | InnoDB

Timeout error occurred when trying to start MySQL Daemon.

If you are getting the following error while trying to start MySQL service;

[root@ ~]# /etc/init.d/mysqld restart
Stopping MySQL:                                            [FAILED]
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL:                                            [FAILED]
[root@ ~]#

And if you are getting the following error in the MySQL log;

[root@ ~]# tail -f /var/log/mysqld.log
080503 14:30:28 [ERROR] Can’t start server: can’t create PID file: No space left on device
Number of processes running now: 0
080503 14:30:28  mysqld restarted
080503 14:30:28  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.

The issue might be due to the lack of space in the ‘/var’ partition. So you need to reduce the disk space, which should fix the issue.

[root@ ~]# df -h
[root@ ~]# cd /var
[root@ ~]# du -sch *

Using the above commands, you can see that files and folders which consumes more size.  You need to delete the unwanted files or folders and try reduce the size.

Try restart the MySQL service. 🙂

[root@  ]# /etc/init.d/mysqld restart
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]
[root@  ]#    

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 ‘/test/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/* /test/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  /test/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

 

MySQL: got error 28 from server handler

This error means no space left on hard disk. If you get his error, you need to check all filesystems where MySQL operates.

a) Stop mysql server
# /etc/init.d/mysql stop
OR
# /etc/init.d/mysqld stop


b) Check filesystem and /tmp directories:
$ df -h
$ cd /tmp
$ df -h /tmp


c) Remove files from /tmp to free up space:
# cd /tmp
# rm -rf *


d) Look into /var/log directory and remove or compress logs file.

e) Use myisamchk command to check and repair of ISAM table:
# cd /var/lib/mysql
# myisamchk


f) Increase disk space (add new hard disk or  remove unwanted softwares)

g) Start the mysql server:
# /etc/init.d/mysql start
OR
# /etc/init.d/mysqld start

 

 

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)

070420 10:07:58 InnoDB: Error: unable to create temporary file; errno: 13
070420 10:07:58 [ERROR] Can’t init databases
070420 10:07:58 [ERROR] Aborting

070420 10:07:58 [Note] /usr/libexec/mysqld: Shutdown complete

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.

 

 

 

 

Upgrade MySQL system tables

When you try to create a remote MySQL user, sometimes  you may get the following the error.

ERROR 1146 (42S02): Table ‘mysql.procs_priv’ doesn’t exist


Why this error occurs?

 

MySQL system tables should be updated while upgrading MySQL version in the server and make sure that their structure is up to date. Otherwise, this error will occur when you create a remote user.

You can eliminate this error by executing the command in command prompt. mysql_fix_privilege_tables –password=root_password

 

This command will update MySQL tables and its structure.

Note: Before executing this command, make sure that you have taken the full backup of MySQL.

 

MySQL: Access denied for user

MySQL Error : Error connecting to MySQL: Access denied for user: ‘root@localhost’ (Using password: YES)

Situation:
If we try to connect mysql, sometimes we get an error as  given below.
          

  Error connecting to MySQL: Access denied for user: ‘root@localhost’ (Using password: YES)


This is mainly caused due to the fact that the user root does not have enough privileges to access the mysql databases or the password set for the user root to connect mysql was changed.

Solution:

Follow the steps below to fix this error.

1. Start mysql using mysqld_safe

#/usr/local/etc/rc.d/mysqld stop
#mysqld_safe –skip-grant-tables &

Note:
mysqld_safe is used to start mysql server by disabling certain feature that restrict a user to access mysql.
The option –skip-grant-tables is used to neglect the permission grant to different users of mysql.

2. Enter mysql prompt by just typing “mysql” and do the following

>GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY ‘newpassword’ WITH GRANT OPTION;
>FLUSH PRIVILEGES;
>\q


3. Kill all mysql processes and start mysqld

#killall -9 mysqld_safe
#killall -9 mysqld
#/usr/local/etc/rc.d/mysqld start


4. Verify the result

# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g
Your MySQL connection id is XXXXX to server version: 4.1.11-standard

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>


 

How to disable directory or file listing for particular website?

a)vi .htaccess

Options All -Indexes

save the changes.

OR

a)vi .htaccess

add this to the file

IndexIgnore *

 

Find help on this link for most of the general soultions regarding directory listing:

http://www.clockwatchers.com/htaccess_dir.html

 

 

How directly run webstat through IE ( i.e domainname.com/webstat)

cd /home/username/public_html

ln -s ../tmp/webalizer webstat

cd ..

chmod 755 tmp

cd tmp

chmod 755 webalizer