When restoring your MySQL databases, if you run into this error:
Unable to add user username_dbuser. String 'username_dbuser' is too long for user name (should be no longer than 16)
Can't add user username_dbuser to username_dbname: Unable to add user username_dbuser. String 'username_dbuser' is too long for user name (should be no longer than 16)
it means that the username_dbuser values are too long for MySQL.
Although there are settings in the mysql.user and mysql.db tables which control then max length of the username, MySQL clearly states that they cannot be changed:
"The limit on MySQL user name length is hard-coded in the MySQL servers and clients, and trying to circumvent it by modifying the definitions of the tables in the mysql database does not work."
The solution (with regards to DA) is to shorten the DA username, so that the total length of the db user is shorter.
There are 2 ways of doing this:
1) Change the existing username
and restore again from that User's backups folder:
where this path is needed, as it's a username independent restore area.
Or delete the existing User, rename the backup to a shorter name, and restore again, eg:
mv user.admin.username.tar.gz user.admin.usern.tar.gz
This last option is more difficult, but will shorten the database name and db usernames, rather than changing the DA username.
- Using this guide
, you can extract the current tar.gz backup file.
- In the "backup" directory, each MySQL database will have 3 files, eg:
Rename those 3 files to have a shorter _dbname
value, so username_dbname is 16 characters, or less.
- Also edit the username_dbname.conf
and change any username_dbuser=
entries which are more than 16 characters.
- Repack the tar.gz.
If you're seeing the word "collation" in the error, ensure you're restoring onto DA version 1.43.0 or newer, with regards to this change: