rename_database_with_user not working as expected

gate2vn

Verified User
Joined
Nov 9, 2004
Messages
489
Location
Oslo
I am using rename_database_with_user.sh script for moving a database from OLDUSER to NEWUSER.

./rename_database_with_user.sh OLDDAUSER_dbname NEWDAUSER_dbname
Dumping+restoring OLDDAUSER_dbname -> NEWDAUSER_dbname...
Database has been renamed successfully: OLDDAUSER_dbname -> NEWDAUSER_dbname
Moving to a new user, granting new user/revoking old user permissions
'NEWDAUSER_dbusername'@'localhost' user does not exist. Creating...
'OLDDAUSER_dbusername'@'localhost' still has privileges for other databases. Not removing the user.

For double checking, the OLDDAUSER_dbusername was used only for OLDDAUSER_dbname, so it didn't have any privileges for other databases.
I tried with different databases, the same result.

A bug in the script?
 
Here is the current documentation. Just in case this could help.

A bug in the script?

here is the part of the script you are referencing

Code:
if [ `${MYSQL} ${DEFM} -s -e "SELECT COUNT(*) FROM (SELECT User,Db,Host FROM mysql.db UNION SELECT User,Db,Host FROM mysql.tables_priv UNION SELECT User,Db,Host FROM mysql.columns_priv UNION SELECT User,Db,Host FROM mysql.procs_priv) tb WHERE User='${OUSER}' AND Db!='${OLDUSER_ESCAPED_DATABASE}' AND Db!='${OLDUSER_DATABASE}' AND Host='${OHOST}'"` -eq 0 ]; then
                    echo "'${OUSER}'@'${OHOST}' does not have privileges for other databases. Removing the user."
                    ${MYSQL} ${DEFM} -e "DROP USER '${OUSER}'@'${OHOST}'"
                else
                    echo "'${OUSER}'@'${OHOST}' still has privileges for other databases. Not removing the user."
                fi

Maybe this will help you determine if there is a bug or you do have users in there.
 
Back
Top