Junaid
Junaid

Reputation: 639

Error writing to database in Moodle in Find and Replace tool

I have moved my moodle database files from old server URLold= (https://example1.com) to new server URLnew=(https://example2.com). Now I want to replace URLold with URLnew in database tables using find and replace tool provided by moodle. But when i perform the operation I am getting this error. What should i do? Please help.

Error I am getting

Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table = REPLACE(table, 'https://example1.com', 'https://example2.com')' at line 1
UPDATE mdl_pma_history SET table = REPLACE(table, ?, ?)
[array (
0 => 'https://example1.com',
1 => 'https://example2.com',
)]
Error code: dmlwriteexception
Stack trace:
line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 895 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 6787 of /lib/adminlib.php: call to mysqli_native_moodle_database->execute()
line 74 of /admin/tool/replace/index.php: call to db_replace()

Upvotes: 0

Views: 1458

Answers (1)

Junaid
Junaid

Reputation: 639

So I got the answer on my own

Had to delete the mdl_pma_history table that was causing the error. The Steps i followed are as follows.

  • Exported the table to .sql file
  • Deleted the table because it was not allowing the script to run
  • Once the script (Find and replace) ran successfully imported the table back

Done.

Upvotes: 0

Related Questions