×


Plesk error Unable to import the dump - Fix it Now ?

Sometimes, Plesk users faces issues which make them Unable to import a database dump.

This issue has to do with the MariaDB version.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Plesk related queries.

In this context, we shall look into how to resolve this Plesk error.


Causes for Plesk error Unable to import the dump

Here, you will see the different errors that cause for the issues while importing the database. 

The users defined in the DEFINER directive has no SUPER privilege. 

CREATE PROCEDURE and CREATE FUNCTION require the CREATE ROUTINE privilege. 

They might also require the SUPER privilege, depending on the DEFINER value. 

Usually, errors will appear as below. Error 1:

ERROR 1227 (42000) at line 1421: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

1. Unable to import the MySQL dump via Subscriptions > example.com > Databases > Import Dump:

Unable to import the ibmimedia_john_database dump:
Unable to restore database ‘ibmimedia_john_database’
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1227 (42000) at line 1421: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
(Error code 22)

2. The MySQL CREATE procedure together with the DEFINER directive is used in the dump several times for different users:

/*!50003 CREATE */ /*!50017 DEFINER=`Ibmimedia John`@% */ /*!50003 Some code */;;
/*!50003 CREATE */ /*!50017 DEFINER=`Bobby Sam`@% */ /*!50003 Some code */;;

3. Each user defined in the DEFINER directive in the MySQL dump have no SUPER privilege in the Tools & Settings > Database Servers > MySQL > User accounts > ibmimedia John > Edit privileges > Administration list.

Error 2:

ERROR 1273 (HY000) at line 29: Unknown collation: 'utf8mb4_unicode_ci'

4. Unable to import a database dump going to Domains > example.com > Databases > database-name > Import Dump:

~~ Unable to import the db_name dump:
ERROR 1273 (HY000) at line 29: Unknown collation: ‘utf8mb4_unicode_ci’
Traceback (most recent call last):
File “/usr/local/psa/admin/sbin/dbbackup”, line 6, in 
File “/usr/local/psa/lib/modules/python/dbbackup/dbbackup.py”, line 99, in main
restore(options, password)
File “/usr/local/psa/lib/modules/python/dbbackup/dbbackup.py”, line 88, in restore
raise Exception(“program ‘mysql’ finished with non-zero exit code: %d” % p.returncode)
Exception: program ‘mysql’ finished with non-zero exit code: 1

5. The current version of MySQL on the server is lower than 5.5.3:

# mysql -V
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1


Solutions for Error1: Unable to import the dump in Plesk

Recently, one of our customers approached us telling us that they are unable to import the dump in Plesk. 

Let's take a look at how we resolve this error.


Solution 1:

Provide all users in the dump with the required SUPER privilege. This means that the database user where the dump was exported from and the database user where the dump is imported to need SUPER privilege: 

1. Firstly, log in to Plesk. 

2. Then, go to Tools & Settings > Database Servers and click the icon opposite to the MySQL database server. 

3. Next, navigate to the User accounts page and click the Edit privileges link opposite the required database user. 

4. Next, mark the SUPER permission in the Administration list and press the GO button. 

5. Import the MySQL dump via Subscriptions > example.com > Databases > Import Dump. 

6. Finally, revoke the SUPER permission from the database user. 

Repeat steps from 2 and 3, then uncheck the SUPER permission in the Administration list and press the GO button.


Solution 2:

Modify the MySQL dump file by removing all DEFINER directives: 

1. Firstly, connect to the server via RDP or SSH. 

2. Then, create a backup of the current MySQL dump file. 

3. Open the MySQL dump file in any text editor. 

4. Finally, find all DEFINER directives in the file and remove them.

[BEFORE]

/*!50003 CREATE */ /*!50017 DEFINER=`John Doe`@% */ /*!50003 Some code */;;

[AFTER]>

/*!50003 CREATE */ /*!50003 MySQL code */;;

 

Solution 3:

On Linux, the following command can be used to remove all DEFINER from the dump file. 

1. Firstly, connect to the server via SSH

plesk db dump bob_john_database | sed -e “s/\/\*[^*]*DEFINER=[^*]*\*\///” > db_without_definer.sql

OR Remove DEFINER from the dump file directly:

sed -i.bak -e “s/\/\*[^*]*DEFINER=[^*]*\*\///” ibmimedia_john_database.sql

2. Then, proceed to import the dump file On Windows, sed for Windows can be used.


Solution for Error2: Unable to import the dump in Plesk

For Linux:

Upgrade MySQL to version 5.5 with the steps given below:


CentOS/RHEL/CloudLinux

1. Firstly, install the Atomicorp repository:

wget -q -O – https://www.atomicorp.com/installers/atomic | sh

2. Then, upgrade MySQL:

yum upgrade mysql

3. Next, restart the MySQL service:

service mysqld restart

4. Upgrade MySQL databases:

mysql_upgrade -uadmin -p`cat /etc/psa/.psa.shadow`

5. Execute this command to update the package version inside Plesk:

plesk bin service_node –update local


For Debian/Ubuntu

1. Firstly, update all system packages:

apt-get update

2. Then, upgrade MySQL:

apt-get upgrade mysql-server

3. Later, restart the MySQL service:

service mysql restart

4. Upgrade MySQL databases:

mysql_upgrade -uadmin -p`cat /etc/psa/.psa.shadow`

5. Execute this command to update the package version inside Plesk:

plesk bin service_node –update local


For Windows:

Upgrade MySQL via Plesk following the steps given below:

1. Firstly, go to Tools & Settings > Updates & Upgrades > Add/Remove Components

2. Then, select “MySQL 5.7 server” for installation.

3. Next, click Continue


[Still, not able to fix Plesk database problems? – We'd be happy to help you. ]


Conclusion

This article covers methods to fix database error in Plesk. 


To fix this Plesk database issue:

1. Start by Checking the version of your SQL server with:

# plesk db -Ne "select version()"

2. Make sure that collation mentioned in the error message is not available in MySQL server:

# plesk db -e "show collation" | grep uft8_general_ci

3. So you have to upgrade MariaDB to version 10.1 or 10.2 on the destination server.


How to upgrade Plesk MySQL 5.5 to 5.6/5.7 or MariaDB 5.5 to 10.X on Linux?

By default, Ubuntu 20.04 is shipped with MariaDB 10.3.

1. For security reasons, create a database dump of all databases with the following command:

MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin --verbose --all-databases --routines --triggers > /tmp/all-databases.sql

2. Stop MariaDB:

$ service mariadb stop

3. Install repositories from Setting up MariaDB Repositories page:

# apt-get install software-properties-common
# apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
# add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.truenetwork.ru/mariadb/repo/10.4/ubuntu focal main'

4. Create a backup of all MySQL data:

$ cp -v -a /var/lib/mysql/ /var/lib/mysql_backup

5. Start an upgrade with the following command. Leave all fields empty when asked for a 'root' user password:

$ apt-get update
$ apt-get install mariadb-server

6. Start the MariaDB service:

# service mariadb start

7. Upgrade MySQL databases:

MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin

8. Restart mysql service:

$ service mariadb restart

9. Execute the following commands to update package version inside Plesk:

# plesk bin service_node --update local
# plesk sbin packagemng -sdf