MySQL

Dump MySQL Schema

Here is the command on how to dump the MySQL database without data:

# mysqldump -u root database_name --no-data=true --add-drop-table=false > schema_dump.sql

  

Create MySQL RPM

To create your own MySQL RPM package, you can:

Change MySQL Password

These articles have detailed instructions on how to change MySQL user password, including root password:

 

 

Tricks on MySQL Alter Table Online

 

MySQL Bin Log

The bin-log files can be find in folders like /var/lib/mysql/. Their filenames are in the format of mysqld-bin.000001, mysqld-bin.000002, ...

To disable bin-logging, comment out the line "log-bin=..." in /etc/my.cnf.

To change the log size, edit the variable value of "max_binlog_size" in /etc/my.cnf.

For more information, reference:

 

Securing MySQL

Remove MySQL from network

By default, MySQL listens on port 3306. Stop it from listening on any TCP/IP port if you don't use it on network.

# vi /etc/my.cnf

Change
#skip-networking
to
skip-networking

Secure the user accounts

A default install of MySQL is somewhat lacking in security. To fix that we are going to do the following:

MySQLdump Encoding

Newer release of mysqldump uses UTF8 as its default charset if nothing is specified, while older versions (older than 4.1 typically) use Latin1 as default characterset.

If your database charset is Latin1 and dump in UTF8 collation, the data may ends up become simply rubbish, garbled, or unreadable.

In the other hand, if you database charset is already in UTF8, when you run mysqldump from a Linux shell, you may still get garbled data. If this happens to you, check your shell's locale
% locale

How to Rename a MySQL Table Column That is a Reserved Word

If you inadvertedly created a table with a column name that 's a reserved word, you will find it not so convenience to use. To rename the column, you can't do something like

mysql> ALTER TABLE table_name CHANGE COLUMN reserved_word new_column_name varchar(255);

Instead, you have to it this way:

mysql> ALTER TABLE `table_name` CHANGE COLUMN `table_name`.`reserved_word` `table_name`.`new_column_name` varchar(255);

 

MySQL InnoDB Error "the table is full"

http://dev.mysql.com/doc/refman/5.0/en/full-table.html explains some common causes for the error "the table is full" and tells how to fix it.

If you are using MySQL InnoDB, and the file limit isn't reaching the maximum file size limit by the operation system, then check your my.cnf config file, and look for a line like

innodb_data_file_path = ibdata1:10M:autoextend:max:128M

Increase the "max:128M" to something bigger, such as "max:526M".

If you want to increase the innodb_log_file_size, do this: