I am trying to run a MySql database with MAMP, but when I try to access the database, this error appears:
SQLSTATE[HY000] [2019] Can't initialize character set UTF-8 (path: /Applications/MAMP/Library/share/charsets/)
I ran "show variables" and found that the charset is set to UTF-8. I also looked in the path mentioned in the error and found that there was no file that said anything about UTF-8, so it appears that this charset is missing. Huh??? If it's looking for this charset, it must usually be present. So why is the charset missing? How can I get it there?
I had a similar problem. In my case I mistyped UTF-8 for establishing the connection.
Try to connect with the charset "utf8" instead of "UTF-8".
Apart from that I also have no UTF-8 charset file in that folder so I guess it's not the real problem.
Related
I did made site on my localhost using Bitnami application,but when i export my database from PhpMyAdminm,and upload to hostting company they told me that they can’t import database because they get the error charset utf 8 collate utf8_general_ci,and i should change charset and collation in my bitnamidatabase.sql file in notepad,but when i opened i noticed that there is plenty lines of code that contains that so i give up,and i also noticed that in my phpmyadmin there is drop-down menu where i can change the charset ,in filed where are the info about database server is this Server charset: UTF-8 Unicode (utf8mb4) for the almost all files in that database collation is utf8mb4_unicode_520_ci,what should i do to fix that ,shoud i change type of collation ih the PhpMyAdmin or what?
I have a Spring App with Tomcat and MySql who runs with no problems in Windows, but when it's running on Linux server, special utf-8 characters (like spanish Ñ) are saved in Mysql table with the ? symbol.
If I change this character directly on the database, it's correctly showed by the app. It's when I save the object using the app when the Ñ is replaced by the ?
Other apps are running on the same server and they don't have this issue.
The data base has the UTF-8 charset/collation.
Can anybody help?
Thanks a million!
Make sure your Datasource URL includes UTF-8 character encoding!
Example:
jdbc:mysql://localhost:3306/databaseName?useUnicode=yes&characterEncoding=UTF-8
you have to put the right encoding in your properties file or in your DataSource URL. (characterEncoding=UTF-8)
I'm using Squeryl to work with a MySQL database. The tables are in utf8mb4 encoding. Now I want to insert some utf8 (4 byte) strings into the db through Squeryl. How do I do that?
I tried to set ?useUnicode=yes&characterEncoding=UTF-8 to my connection url but apparently, UTF-8 here is 3 byte to MySQL so it doesn't work.
I found this StackOverflow answer, but after some digging, I don't see anyway to append my queries with SET NAMES utf8mb4; (changing database config and environment is not an option)
Example string: อลิซร้องเพลงตามเลยค่ะ😂😂😂
Error when trying to insert the string:
Exception in thread "main" org.squeryl.SquerylSQLException: Exception while executing statement : Incorrect string value
Be sure not to connect as root.
Have this in my.cnf (in the [mysqld] section)
init_connect = SET NAMES utf8mb4
My problem:
I'v been given a mysql database in a non-English language (Persian or Farsi, & if you don't know what kind of language is that, it's like Arabic). The records were entered through a web interface by php, using a windows machine. When I want to view the database using phpMyAdmin in xampp, the records look like this:
مرکز آموزش توپخانه نزاجا
If I edit the records in phpMyAdmin, I can add non-English (Persian) characters and they look fine, only the existing data is incorrectly displayed.
I've been provided with a .sql backup file as well, but when I open it in Notepad++ it doesn't look right either. I also tried "Encode in UTF-8" in Notepad++, but no use.
What I want:
A correct representation in phpMyAdmin or a healthy .sql file.
What I have:
xampp 1.8.2 (Apache 2.4.4, MySQL 5.5.32, PHP 5.4.16, phpMyAdmin 4.0.4), win 7 x64
The files I have:
.frm .MYD .MYI files (which I copied to xampp\mysql\data\mxpro), the .sql file i mentioned (mxpro.sql) & db.opt file containing these 2 lines:
default-character-set=utf8
default-collation=utf8_general_ci
I've found this line included inside the .sql file:
CHARSET=latin1
All of these files are inside a folder called 'mxpro' located in xampp\mysql\data\.
The collation of the table columns in the phpMyAdmin are: latin1_swedish_ci
What I have tried:
First of all, when I open the MYI file in Notepad++ and use "Encode in UTF-8", I can see most of the data sitting there in the correct format (Persian).
I've tried the following based on my research:
1) Changing whatever I see to utf8_general_ci, including: database (mxpro) collation (through operations), table collation (through operations), columns collation & server connection collation (in general settings)
2) Changing these server variables to utf8: character set client, character set connection, character set database, character set results, character set server & character set system.
3) Changing these server variables to utf8_unicode_ci: collation connection, collation database & collation server.
4) Adding this line:
#MySQL_Query("SET NAMES utf8");
to xampp\php\pear\MDB2\Driver\mysql.php after this line:
$connection = #call_user_func_array($connect_function, $params);
5) Adding these 3 lines to my.ini:
collation_server=utf8_unicode_ci
character_set_server=utf8
skip-character-set-client-handshake
6) Adding these 2 lines:
mysqli_query($link, "SET SESSION CHARACTER_SET_RESULTS =latin1;");
mysqli_query($link, "SET SESSION CHARACTER_SET_CLIENT =latin1;");
to xampp\phpMyAdmin\libraries\dbi\mysql.dbi.lib.php, below the following line:
PMA_DBI_postConnect($link, $is_controluser);
7) Changing this:
'utf-8' => 'utf8',
to this:
'utf-8' => 'latin1',
in xampp\phpMyAdmin\libraries\select_lang.lib.php
despite my efforts, no outcome yet.
Thank you in advance.
On the phpMyAdmin wiki, there is an article explaining this issue:
http://wiki.phpmyadmin.net/pma/Garbled_data
I used this query on my db and it's worked perfectly
ALTER DATABASE yourDB CHARACTER SET utf8 COLLATE utf8_bin
I had to make change to my directory path in a lot of posts. I decided to export the DB and do a find/replace to makew the changes. But when I imported the DB back i got the error
1064 - You have an error in your SQL syntax;
which I think it becuase of mt charset not understanding them ampersand & amp;
How can I import this
It might help if you first change the file from utf-8 to iso-8859-1 with a command line program.
Start a command line session and change directory so you are in the directory that this file is in and enter the command
iconv -cs -f UTF-8 -t ISO-8859-1 utf8.txt > iso.txt
If you do not have access to a linux command line use google to find a windows method to convert between utf8 and iso character sets.
You've not given much information in the question but I'd recommend the following approach:
Restore from your last backup
Have a look at MySQL's REPLACE() function. It should be able to do your find/replace work all in the database