用错误的排序规则连接到mysql服务器?

I have a Golang program that may connect to databases with different character sets or collation.

For example the default at the time of writing of the Golang MYSQL driver is utf8mb4_general_ci https://github.com/go-sql-driver/mysql#collation

However if I connect to a database configured like so:

CREATE DATABASE example character set utf8mb4 collate utf8mb4_unicode_ci;

Can I expect "bad things to happen"? Indexes not to work?

In most case, there are no problem. For example, column collation is used regardless connection collation when WHERE column=? is used.

See also: https://dev.mysql.com/doc/refman/5.6/en/charset-collation-coercibility.html

But I can't speak it's 100% safe. It's safe to use one collation all place.