Migrating

Migrating

by James Steerpike -
Number of replies: 2

I have been running a 2.7 database on shard hosting and want to move it to my home server.

First I installed Debian 9, then Apache, MySql and PHP 7. The MySql turned out to be Mareia DB but I had an empty Moodle. I dumped the Moodle database and moved Moodledata to another area - so I could restore the install later if required.

I dumped the database on the host and ftped the Moodledata directory to replace the moodledata directory on my machine. I then tried restoring the hosted database to my new install.

Command 1: mysqlimport -umoodleuser -p moodle  hosted.sql

mysqlimport: Error: 1045, Access denied for user 'moodleuser'@'localhost' (using password: YES), when using table: hosted

Password and user were correct as I can log in to the database.

I then tried within mysql

mysql -umoodleuser -p moodle < hosted.sql

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'mysql - moodleuser - moodle < hosted.sql' at line

Can anyone see what I am doing wrong?

r


Average of ratings: -
In reply to James Steerpike

Re: Migrating

by Ken Task -
Picture of Particularly helpful Moodlers

Try:

mysql -u [superuser] -p'[password]' [database4moodle] < [sql_file_name_to_import].sql

Variables in []'s above you adjust - replacing the entire example ... including the []'s.

In your commands, you didn't tell them what database to use on import. ;)

There is no space after the -p and tick/quote the password just in case that password has characters that might confuse your bash shell mysql command.

MySQL/MariaDB, when first installed, should step you through a first time setup of a secure install where you setup a superuser (like root for the OS).  Use that 'superuser'.

But ... there is a potential issue ... am not sure a 2.7 of Moodle will run under 7.0.x of PHP.

Think the first version of Moodle that could run under PHP 7.0.x was 3.0.1.

For mimimum PHP requirements see:

https://download.moodle.org/releases/legacy/

and the section on 2.7.x version.

'spirit of sharing', Ken



In reply to Ken Task

Re: Migrating

by James Steerpike -

Thanks Ken. Problem was in the moodleuser, reference to superuser set me straight. I had created a root user earlier in the install and a moodleuser later, looks like only root could restore.

I had the database as moodle - but I had removed my password in the code snippet.

Not quite there yet - Moodle is up but refusing access. Job for tomorrow.....