Error connecting to MariaDB from python: Unknown collation: ‘utf8mb4_unicode_520_ci’

On my production server (Debian 12) I have a mariadb database, ‘sasquatch_index’, that works as expected with a few python scripts that interface with it. I am in the process of setting up my application to work in a testing environment and I want to copy this database to my local system (Manjaro). On my production server I use a command like mariadb-dump -u [username] -p[password] sasquatch_index > ./site_dump.sql To create the site_dump.sql file. I than retrieve this file from my local machine using rsync. I initiate the database on my local machine with mariadb -u [user] -p sasquatch_index < ~/site_dump.sql. I can access this database and its contents via the mariadb client. So far so good.

Issues arise however, when I try to use any of the python scripts that exist to interface with this database on my local machine (The testing environment I am setting up). Said scripts make use of a ‘mysql.connector’ module that was installed via the command pacman -S python-mysql-connector. For example, search.py exists to preform complex searches against the database. It is run via a command like search.py -s "hello world" And it returns an erroneous output like the following:

Error connecting to database: 1273 (HY000): Unknown collation: 'utf8mb4_unicode_520_ci'
Traceback (most recent call last):
  File "/home/josh/git/github/search-sasquatch/./search.py", line 270, in <module>
    main()
  File "/home/josh/git/github/search-sasquatch/./search.py", line 262, in main
    results = performSearch(arguments['searchString'], arguments['safe'], creds)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/josh/git/github/search-sasquatch/./search.py", line 185, in performSearch
    if conn is not None and conn.is_connected():
       ^^^^
UnboundLocalError: cannot access local variable 'conn' where it is not associated with a value

(note the part of the output relating to “Unknown collation.” The value of the variable named ‘conn’ is dependent on making a successful connection to the database.)

Another instance where this “Unknown collation” error appears is when trying to use another one of these python scripts. This particular one, ‘extractor.py’, appends new data to a table in the ‘sasquatch_index’ database table called ‘sites’. The output of running this script on the local system looks like this:

Parsing https://example.com/index.php...
Error updating the database for url 'https://example.com/index.php': 1273 (HY000): Unknown collation: 'utf8mb4_unicode_520_ci'
Parsing https://josh.example.com...
Error updating the database for url 'https://josh.example.com': 1273 (HY000): Unknown collation: 'utf8mb4_unicode_520_ci'

These scripts work perfectly as expected in the production environment, but locally, they produce errors like this.

I’ve tried modifying the command I ran on the production server to explicitly not use collation ‘utf8mb4_unicode_520_ci’ i.e mariadb-dump --default-character-set=utf8mb --skip-set-charset -u [user] -p[password] sasquatch_index > site_dump.sql

I’ve also searched the ‘site_dump.sql’ file for the string “utf8mb4_unicode_520_ci” and have discovered that said text never occurs inside this file. All the while these errors still occur.

Most recently, I’ve tried running ‘extractor.py’ without importing anything (I created the database and table using other scripts from my project) and I continue to get the same errors. ‘extractor.py’ is still unable to add any data to the sites table.

New contributor

joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật