Articles in the ‘MySQL’ Category

Clear MySQL bin log files

Monday, December 12th, 2011

You need MySQL bin logs only if you are replicating the databases.

1. Disable bin logging
nano /etc/my.cnf
2. Comment all bin logging related lines

#log_bin = /var/log/mysql/mysql-bin.log
#expire_logs_days = 10
#max_binlog_size = 100M

3. Restart MySQL
4. Delete the bin log files by entering in mysql with:
mysql
5. Run the following command:
PURGE BINARY LOGS TO 'mysql-bin.03';

where 03 is the last number of the bin log you want to clear.

Convert MYSQL tables to INNODB script

Tuesday, July 12th, 2011

If you want to convert MYSQL tables to INNODB use the following script:

mysql -u root -p -e "SHOW TABLES IN DATABASE-NAME;" | tail -n +2 | xargs -I '{}' echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql
and then run:
perl -p -i -e 's/(search_[a-z_]+ ENGINE=)INNODB/\1MYISAM/g' alter_table.sql

Replace “DATABASE-NAME” with your database name. You also need root access (preferably).

How to import large .sql files into MySQL via shell?

Thursday, October 1st, 2009

If you seek to import a large MySQL file via the shell in Linux, the following command might be helpful to you:

shell>mysql -uusername -ppassword db_name < dumpfile.sql

If you are already running mysql, you can execute an SQL script file using the source or \. command:

mysql> source dump.sql
mysql> \. dump.sql

How to connect to MySQL over SSH tunnel

Thursday, May 21st, 2009

Short turorial on how to connect to a server offering public ssh access but no mysql port, using putty and MySQL Administrator pack.

Requirements: prior knowledge of putty and MySQL Administrator usage.

Downloads:

- putty : http://tinyurl.com/co2zg4

- MySQL Administrator: http://tinyurl.com/ph3lg6

Step1: First load your already created session, or change settings while connected, and go to Configuration > Connection > SSH > Tunnels

step1

Step 2: Press Add

step2

Step 3: enter your details as pictured (username/password are user provided) and click OK.

step3

Final note: Compression should be enabled on the SSH connection (if possible) or at the MySQL connection screen.