Data Exchange between different MySQL Databases

20. Februar 2011

To exchange data between different MySQL databases use the INSERT…SELECT syntax.

If both tables are identical:

INSERT INTO database2.table1
SELECT *
FROM database1.table1
WHERE 1;

To insert the value of selected columns use:

INSERT INTO database2.table1 (column1)
SELECT column1
FROM database1.table1
LIMIT 1;

This only works, if both databases are hosted on the same MySQL server! There is absolutely no way to exchange data between different/remote MySQL servers using standard (My)SQL syntax!

If you intend to access data from different/remote MySQL server, use the FEDERATED storage engine (cf. the MySQL website), which allows you to execute local queries on the remote database.


The inevitable common sense caution: Use at your own risk!

Install Sun Java under Debian Squeeze

18. Februar 2011

Debian Squeeze for AMD64 comes with OpenJDK Java preinstalled and ready to run. If you, for whatever reason, need to install Sun Java, the Sources list has to be modified:

Edit /etc/apt/sources.list, add “non-free”:

deb http://ftp2.de.debian.org/debian squeeze main non-free

Update:

ron@ron:~$ apt-get update

Check for available Sun Java Packages:

ron@ron:~$ apt-cache search sun-java6

The result may look something like this:

sun-java6-bin - Sun Java(TM) Runtime Environment (JRE) 6 (architecture dependent files)
sun-java6-demo - Sun Java(TM) Development Kit (JDK) 6 demos and examples
sun-java6-doc - Sun JDK(TM) Documention -- integration installer
sun-java6-fonts - Lucida TrueType fonts (from the Sun JRE)
sun-java6-javadb - Java(TM) DB, Sun Microsystems' distribution of Apache Derby
sun-java6-jdk - Sun Java(TM) Development Kit (JDK) 6
sun-java6-jre - Sun Java(TM) Runtime Environment (JRE) 6 (architecture independent files)
sun-java6-plugin - The Java(TM) Plug-in, Java SE 6
sun-java6-source - Sun Java(TM) Development Kit (JDK) 6 source files

Now install what you need, minimum is sun-java6-bin:

ron@ron:~$ apt-get install sun-java6-bin sun-java6-javadb sun-java6-jdk sun-java6-plugin

In order to accept the License Agreement, navigate to the Accept field with TAB.

Make Sun Java the Java runtime of your choice:

ron@ron:~$ update-java-alternatives -s java-6-sun

Check, if Java could be properly installed:

ron@ron:~$ java -version

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

Set Environment Variable $JAVA_HOME

Edit file /etc/profile, add:

JAVA_HOME="/usr/lib/jvm/java-6-sun"
export JAVA_HOME

Done!


The inevitable common sense caution: Use at your own risk!

MySQL 5.5 Server as Replication Slave

16. Februar 2011

I had some trouble configuring a MySQL 5.5 Server as Replication Slave as I c&p’ed the configuration data into the slaves’s my.cnf: MySQL did not not start.

A look into the error-log showed:

[ERROR] /opt/lampp/sbin/mysqld: unknown variable 'master-host=1$
[ERROR] Aborting

Obviously the Replication Master data cannot be set in slave my.cnf for MySQL 5.5 Server, though the my.cnf sample files still proposes this.

To define the Replication Master connect through a shell to your MySQL server and enter:

mysql> CHANGE MASTER TO MASTER_HOST='N.N.N.N',
MASTER_PORT=N,
MASTER_USER='NAME',
MASTER_PASSWORD='PASSWORD';

This will create a master.info file, where this data and information about the master bin-log and the log position is stored.

Start the replication:

mysql> START SLAVE;

Confirm your configuration:

mysql> SHOW SLAVE STATUS \G;


The inevitable common sense caution: Use at your own risk!

Fight error with error

15. Februar 2011

My Eclipse IDE says:

An internal error occurred while showing an internal error. You are recommended to exit the workbench. …

Do you want to exit the workbench?


The inevitable common sense caution: Use at your own risk!