Skip to main content

MySQL/MariaDB create view error Illigal mix of collations

https://dba.stackexchange.com/questions/170610/how-to-retrieve-the-query-i-used-to-create-a-view




SHOW CREATE VIEW not work since it will dump create command within CONVERT()

Example:
 CREATE ALGORITHM=UNDEFINED DEFINER=`user`@`%` SQL SECURITY DEFINER VIEW `ViewFollowAndFollowerCount` AS select `t1`.`user_id` AS `user_id`,`t4`.`user_name` AS `user_name`,`t2`.`followCount` AS `followCount`,`t3`.`followerCount` AS `followerCount`,`t1`.`created_at` AS `follow_created_at` from (((`UserFollowData` `t1` left join `ViewFollowCountGroupByUserId` `t2` on((`t1`.`user_id` = `t2`.`user_id`))) left join `ViewFollowCountGroupByFollowUserId` `t3` on((`t1`.`user_id` = `t3`.`follow_user_id`))) left join `UserData` `t4` on((convert(`t1`.`user_id` using utf8mb4) = `t4`.`user_id`)))

I got error something like: "Illegal mix of collations "

This caused by CONVERT() on dump /export (?) when convert collation ie. to utf8mb4...
Detail here https://bugs.mysql.com/bug.php?id=54278
So to fix/ work around I have to export / show create view without convert().

https://stackoverflow.com/questions/8150804/how-to-fix-a-broken-sql-view

SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v';

 More about error detail:


After that I can create view. However some view I got another error:

ERROR 1356 (HY000): View 'yourdb.ViewFollowCountGroupBy' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

This somehow related to permissions:

https://www.shellhacks.com/mysql-show-users-privileges-passwords/
https://chartio.com/resources/tutorials/how-to-grant-all-privileges-on-a-database-in-mysql/

So to show user grant:
 SHOW GRANTS FOR 'user_name';
or SHOW GRANTS;

https://stackoverflow.com/questions/2126225/why-is-a-grant-usage-created-the-first-time-i-grant-a-user-privileges
https://sites.google.com/site/nazmulhudadba/error-1372-hy000-password-hash-should-be-a-41-digit-hexadecimal-number
https://stackoverflow.com/questions/20070988/mysql-error-1356-views
https://bugs.mysql.com/bug.php?id=76484

https://easyengine.io/tutorials/mysql/remote-access/
I don't know (or not pay attention) that root or any MySQL user can have different password on different HOST, I mean root can have no password with @localhost but have 'password' on other IP or internet '%'.


Comments

Popular posts from this blog

Rand mm 10

https://stackoverflow.com/questions/2447791/define-vs-const Oh const vs define, many time I got unexpected interview question. As this one, I do not know much or try to study this. My work flow, and I believe of many programmer is that search topic only when we have task or job to tackle. We ignore many 'basic', 'fundamental' documents, RTFM is boring. So I think it is a trade off between the two way of study language. And I think there are a bridge or balanced way to extract both advantage of two method. There are some huge issue with programmer like me that prevent we master some technique that take only little time if doing properly. For example, some Red Hat certificate program, lesson, course that I have learned during Collage gave our exceptional useful when it cover almost all topic while working with Linux. I remember it called something like RHEL (RedHat Enterprise Linux) Certificate... I think there are many tons of documents, guide n books about Linux bu

Martin Fowler - Software Architecture - Making Architecture matter

  https://martinfowler.com/architecture/ One can appreciate the point of this presentation when one's sense of code smell is trained, functional and utilized. Those controlling the budget as well as developer leads should understand the design stamina hypothesis, so that the appropriate focus and priority is given to internal quality - otherwise pay a high price soon. Andrew Farrell 8 months ago I love that he was able to give an important lesson on the “How?” of software architecture at the very end: delegate decisions to those with the time to focus on them. Very nice and straight-forward talk about the value of software architecture For me, architecture is the distribution of complexity in a system. And also, how subsystems communicate with each other. A battle between craftmanship and the economics and economics always win... https://hackernoon.com/applying-clean-architecture-on-web-application-with-modular-pattern-7b11f1b89011 1. Independent of Frameworks 2. Testable 3. Indepe