Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

MySQL Failed to enable constraints. One or more rows contain values violating non-null, unique, ...

Hello,

 

I am receiving an error while trying to connect to a MySQL database (using the MySQL data source) with Power BI:

 

2022-04-04 13_38_19-Window.png

 

It translates to:

Details: "An error happened while reading data from the provider: 'Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.'"

 

The weird thing is that the error does not occurr with databases served by the localhost mysql server, but with the internal network one. The database itself doesn't seem to be the problem - dumping the remote server, restoring it locally and then importing it into Power BI works flawlessly. I never tried connecting to a MySQL database not on localhost before so I don't know if this has always been like this.

 

There is no issue with connecting to the remote DB with MySQL workbench or pymysql

 

If I add a SQL query that select a table it also works instead of letting Power BI do the "work" then there are no issues. I want to avoid manually defining the SQL query.

 

- I uninstalled the MySQL NET connector and installed the current one MySQL :: Begin Your Download, 64 bit, like my system

- restarted my machine

- replicated on another machine

- tried the ODBC version of the Power BI import - MySQL is not in Power BI ODBC selection, but listed in ODBC Data Sources 64 bit, so I could not try if the ODBC version of the MySQL import works

 

2022-04-04 14_13_07-Window.png

Installed MySQL ODBC Connector, not used / available in Power BI

 

 

2022-04-04 14_04_19-Window.png

Used for import of MySQL DB in Power BI

 

Does anyone know what could be the reason for this / a solution?

4 REPLIES 4
PaulJackson
New Member

I got this error by installing and starting PowerBI, trying to make some MySQL connections, uninstalling the MySQL Connector (which included the ODBC driver), they making a MySQL connection. Reinstalling the connector and restarting PowerBI fixed the problem.

Anonymous
Not applicable

I am still facing that issue - does anyone else have an idea on how to solve my problem / what else I could try out?

ghoshabhijeet
Solution Supplier
Solution Supplier

@Anonymous  I would suggest to use the available MySQL Connector in Power BI.

ghoshabhijeet_0-1649075091242.png

 


** If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution, so that it comes in top of the search and help others. Thank you !

Good Luck 👍

 

 

Anonymous
Not applicable

Hello @ghoshabhijeet,

thanks for your answer.

 


brst_0-1649075774563.png

 

 




> Used for import of MySQL DB in Power BI

 

As stated in my post, I did indeed use the MySQL connector. I mentioned the ODBC way as another thing I tried out unsuccessfully.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors