Posts tagged ‘mysql’

redmine: move wiki-pages to a different project

currently just the commands:

SELECT id,name FROM projects;
SELECT * FROM wikis;
SELECT * FROM wiki_pages limit 10;
SELECT * FROM wiki_pages WHERE wiki_id = '1' AND title = 'Howtos';
SELECT * FROM wiki_pages WHERE parent_id = '34';
SELECT * FROM wiki_pages WHERE parent_id in (SELECT id FROM wiki_pages WHERE parent_id = '34');
UPDATE wiki_pages SET wiki_id = '12' WHERE wiki_id = '1' AND title = 'Howtos';
UPDATE wiki_pages SET wiki_id = '12' WHERE parent_id = '34';
-- UPDATE wiki_pages SET wiki_id = '12' WHERE parent_id in (SELECT id FROM wiki_pages WHERE parent_id = '34');
UPDATE wiki_pages SET wiki_id = '12' WHERE parent_id = '35';
UPDATE wiki_pages SET wiki_id = '12' WHERE parent_id = '87';

Monitoring MySQL queries

Monitor All SQL Queries in MySQL is a very nice (though short) posting about how to debug and monitor what’s going on inside your DBMS. There’s supposed to exist a similar tool for MSSQL called “Profiler”.

restoring a MySQL dump on a freshly installed debian/ubuntu system

to restore a dump from a MySQL database created on a debianish Linux system, just feed the dumped SQL to the command-line mysql client like this:

mysql -u root -p < mysql-all-2010-03-28-0515.sql

since the whole content of all MySQL databases are overwritten with that stored in the dump, credentials are affected as well. that’s the reason why debian’s system tools won’t work any more after restoring the old dump, since debian creates a maintenance-user called “debian-sys-maint” during the installation and stores the randomly generated credentials in “/etc/mysql/debian.cnf” so it’s sufficient to just copy the “password” values from the old file into the new one and restart mysql. otherwise, you will run into an error like this:

/etc/mysql/debian-start[3181]: Running 'mysqlcheck'...
/etc/mysql/debian-start[3181]: /usr/bin/mysqlcheck: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) when trying to connect
/etc/mysql/debian-start[3181]: FATAL ERROR: Upgrade failed

installing Funambol on ubuntu 9.10 x86_64 using MySQL as a backend

NOTE: this posting is still very incomplete!!

make sure the 32-bit variants of Java and the corresponding MySQL-connector are installed:

sudo aptitude install ia32-sun-java6-bin libmysql-java

then, adjust the install.properties to use MySQL:

--- ds-server/install.properties.orig	2010-02-13 16:54:13.000000000 +0100
+++ ds-server/install.properties	2010-02-13 16:44:22.000000000 +0100
@@ -21,7 +21,8 @@
 #   - postgresql
 #   - mysql
 #
-dbms=hypersonic
+#orig# dbms=hypersonic
+dbms=mysql
 
 #
 # JDBC settings:
@@ -58,13 +59,20 @@
 # jdbc.user=funambol
 # jdbc.password=funambol
 #
+jdbc.classpath=/usr/share/java/mysql-connector-java.jar
+jdbc.driver=com.mysql.jdbc.Driver
+jdbc.url=jdbc:mysql://localhost/funambol?characterEncoding=UTF-8
+jdbc.user=funambol
+jdbc.password=funambol
+#
 #
 
-jdbc.classpath=../tools/hypersonic/lib/hsqldb.jar
-jdbc.driver=org.hsqldb.jdbcDriver
-jdbc.url=jdbc:hsqldb:hsql://localhost/funambol
-jdbc.user=sa
-jdbc.password=
+#orig# jdbc.classpath=../tools/hypersonic/lib/hsqldb.jar
+#orig# jdbc.driver=org.hsqldb.jdbcDriver
+#orig# jdbc.url=jdbc:hsqldb:hsql://localhost/funambol
+#orig# jdbc.user=sa
+#orig# jdbc.password=
 
 #
 # Modules definitions

next, disable (or delete if you like) the included Java and hypersonic-DBMS:

mv -v tools/jre-1.5.0 tools/jre-1.5.0.disabled
mv -v tools/hypersonic tools/hypersonic.disabled
export JAVA_HOME=/usr/lib/jvm/ia32-java-6-sun/jre
export JRE_HOME=$JAVA_HOME

MySQL backup user

to create a user for doing automated backups of a MySQL installation that doesn’t have more than the necessary privileges, use the following statement:

GRANT RELOAD, SELECT, LOCK TABLES ON *.* TO 'backup'@'localhost' IDENTIFIED BY 'some_reasonable_password';