mysql-migrator
mysql-migrator copied to clipboard
Unexpected record count in target table 'users'. Got 2, expected 1
Hi there,
I am trying to migrate out 7.6 SonarQube server from MySQL to Postgres, in preparation to update to 8.0. I am trying to DB converter tool: mysql-migrator It fails however with the following error: "Unexpected record count in target table 'users'. Got 2, expected 1"
Indeed there are 2 users in the target DB: postgres and sonar I created the later one, as I think that is a best practice not to use the 'root' user.
Please advice.
Thanks, Tamas
For anyone still bumping into this, look at the psql
output of select * from users
. If there is more than 1 user there, i.e. not just the Administrator, then the second one is probably a temporary or non-important one added because you or someone/something else started using the UI or the REST API. Because you are dealing with an initial PostgreSQL database, deleting that second user should be safe, and that is what I did too.
postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} sonar | | {}
I get exactly the same exception while migrating from Sonarqube 6.7(mysql) to 6.7(postgres) Is the issue for sure at the target db i.e postgres as I dont see any user other than administrator.
Thanks Midhun
@MidhunChowdary The issue isn't related to the Postgre users, this is related to the SonarQube users in the "users" table. Look at @rkrisztian comment above.
FYI If you see this
postgres=# select * from users ;
ERROR: relation "users" does not exist
LINE 1: select * from users ;
Then when logging into psql you might need to specify the database name
eg
psql --dbname=sonarqubedb
I assume I had multiple users because I booted up the target/PostgreSQL sonarqube instance (to check that sonarqube was configured correctly and would boot) and then logged in (I can see my non admin LDAP user in the user list).
Suggested sql to search and delete (cause I had to lookup the delete command, and I imagine someone else will have forgotten too)
To search the db for the users
select * from users ;
To remove the extra users I did
delete from users where login != 'admin';