Table of contents
    1. 1. Linux
    2. 2. Windows

    When you create a database using CreateDB.sh, you also add a number of stored functions and procedures, which are system-wide, as opposed to just belonging to the wikidb database.

    If you restore a database from another Deki, you do not get these added.  You should always create a database with the correct version of CreateDB.sh before restoring a database.

    If you did not, there is a workaround. 

    Linux

    Change to /var/www/dekiwiki/maintenance and run the following commands.  The first five lines set up variables (much as CreateDB.sh does with its command-line parameters) and you should set them to match your MySQL user, server, database, admin user and admin password, respectively.  Take the code, add it to a file and call it update-sprocs.sh.  Once you have that then you can execute from the console by running   sh update-sprocs.sh

     

    #!/bin/bash
    # edit the db_ variable assignments before executing them
    db_wiki_user=wikiuser
    db_server=localhost
    db_name=wikidb
    db_admin_user=root
    db_admin_password=password
    MYSQL=`which mysql`
    # create stored procs
    cat archives/sprocs-*.sql | sed -e "s/{\$wgDBuser}/${db_wiki_user}/" -e "s/{\$wgDBserver}/${db_server}/" -e "s/{\$wgDBname}/${db_name}/" -e "s/{\$wgDBadminuser}/${db_admin_user}/" -e "s/{\$wgDBadminpassword}/${db_admin_password}/" | ${MYSQL} -u ${db_admin_user} -p${db_admin_password} -h ${db_server} ${db_name}
    
    # create mysql FUNCTIONS
    cat archives/funcs-*.sql | sed -e "s/{\$wgDBuser}/${db_wiki_user}/" -e "s/{\$wgDBserver}/${db_server}/" -e "s/{\$wgDBname}/${db_name}/" -e "s/{\$wgDBadminuser}/${db_admin_user}/" -e "s/{\$wgDBadminpassword}/${db_admin_password}/" | ${MYSQL} -u ${db_admin_user} -p${db_admin_password} -h ${db_server} ${db_name}
    

     

    Windows

     On Windows change to the Web directory of MindTouch and then to the maintenance directory, you will need GNU cat and GNU sed, both of which are attached to this page. Do the variable substitutions in the command line yourself, like so:

    REM create stored procs
    cat archives/sprocs-*.sql | sed -e "s/{\$wgDBuser}/wikiuser/" -e "s/{\$wgDBserver}/localhost/" -e "s/{\$wgDBname}/wikidb/" -e "s/{\$wgDBadminuser}/root/" -e "s/{\$wgDBadminpassword}/(passwordhere)/" | mysql -u root -p(passwordhere) -h localhost wikidb
    
    REM create mysql FUNCTIONS
    cat archives/funcs-*.sql | sed -e "s/{\$wgDBuser}/wikiuser/" -e "s/{\$wgDBserver}/localhost/" -e "s/{\$wgDBname}/wikidb/" -e "s/{\$wgDBadminuser}/root/" -e "s/{\$wgDBadminpassword}/(passwordhere)/" | mysql -u root -p(passwordhere) -h localhost wikidb
    

     

    Replace values for wikiuser, localhost, wikidb, root and password as appropriate.  You will need to put cat and sed somewhere in your path, or the maintenance directory itself.

    Was this page helpful?
    Tag page (Edit tags)

    Files 1

    FileSizeDateAttached by 
     cat-sed.zip
    cat and sed from GNUwin32
    794.17 kB01:23, 2 Jan 2009crbActions
    Viewing 3 of 3 comments: view all
    The instuctions above are supposed to be run on the prompt. As they are somewhat long, you may want to run them in a shell script:
    Copy the instructions as a *.sh file into the maintenance directory using Windows explorer
    Then, in the shell:
    add "exit" on the last line and save it
    change the file rights to allow execution> chmod 755 sqlfix.sh
    run the shell script> ./sqlfix.sh
    Posted 16:58, 5 Jul 2009
    So do you run CreateDB.sh before you create a new database called wikidb?
    Or afterwards, but before importing the sql file into it?
    Posted 17:56, 5 Jul 2009
    The command for Windows is actually a little off.
    At the end of both commands it should read:

    mysql -u root -p -h localhost -D wikidb

    it would give me errors about my password being the database if i put it into the command. Also, the -D at the end is required to specify the database (wikidb is the default DB name).

    I hope this helps anyone on a windows box =)
    Posted 01:05, 30 Mar 2010
    Viewing 3 of 3 comments: view all
    You must login to post a comment.
    Powered by MindTouch 2010
    Powered by MindTouch 2010