MySQL data type with Chinese characters - mysql

I want to insert Chinese characters as input into my MySQL database. What should be the datatype for it? I have already seen that data type should be NVARCHAR but my database is not taking it.

Use UTF-8 columns for storing non-English characters in your database. See here for some more help.
As it says, use VARCHAR to save space.

Follow the below Steps:
Step 1: Download the chinese character from google.
Step 2: Then include it in your fonts folder which is in Control Panel
Step 3: Restart your system
Then it works!!

Related

How can I fix the weird looking character in database in proper way without loosing my data MYSQL?

I came up with the weird situation with my database. My site is already in production and there are lots of data. I need to export CSV file for the client and give them CSV file. I am using my database export button to export my data in CSV file.
My Problem
While exporting CSV file the polish characters are the unreadable character like ą,ć,ó,ś.Means these characters are changed to an unreadable character like "?". Are lots of data so is impossible to change in CSV file manually.
Mistake
I mistakenly set my character set "latin1" and collation "latin1_swedish_ci".
Question
Is it possible to get back this unreadable character into the readable format without losing these data?
I try to googled and try something like https://nicj.net/mysql-converting-an-incorrect-latin1-column-to-utf8/ but no luck.
Any solution?
Thanks in advance.
Reading that the Queston asker wants to know how to update columns to the correct character set in PHPMyAdmin:
1) In PhpmyAdmin Select the table you want to update.
2) Select "Operations" from the top menu
3) Under "Table Options" you want to select the Collation you want to use,
4) And also tick the box stating
Change all column collations
5) Click Go.
All your table data will now be reformed into full UTF-8.
NOTE:
This means that each "char" in a "varchar" is now equal to 4 chars so it can cause some issues with using indexed column keys prior to MySQL 5.7 as indexes were limited to 767 bytes and UTF-8 characters are 4 bytes each -- this an indexed VARCHAR column of 255 characters would be 255 * 4 = 1020 and so exceed the index limit.

UTF-8 weird behaviour between HTML/PHP forms and MySQL (Hindi)

I have all my database/tables and columns set to UTF-8_general_ci collation set.
Conditions that I Faced :-
When I insert hindi data manually by phpmyadmin, I can see the the hindi characters in phpmyadmin, while question marks when seen on webpage generated by PHP
In the same table when I insert data by HTML/PHP Forms I see some unrecognizable words in english something like cc2faa;(something like this) and Correct Hindi on Webpage.
For the large data we have a script that reads from txt files and insert the data in the table in this , I see characters like जाना in phpmyadmin but Hindi On webpage.
Now the main problem is :-
Data has gone under changes online by forms and now I need this data to export to excel and give to the client but I am getting जाठin excel instead of Hindi Characters.
Note :-
All English characters are working fine and as it is everywhere.
My CHARACTER SET is utf8 For all tables.
I tried to change the collation to UTF-8_bin but that too doesn't helped me in anyway.
Encoding on the browser is UTF-8, and I have already sent the headers for UTF-8 encoding.
I have seen many posts about utf8 problem but no one seem to have this weird different behavior problem.
Please Do I have any rescue from this?? Or finally have to give the PHP reports of the data??
Please help!!
When I insert hindi data manually by phpmyadmin, I can see the the hindi characters in phpmyadmin, while question marks when seen on webpage generated by PHP
PHP probably generates the question marks because the encoding of the database connection is not utf-8. How to fix this depends on the database library you use; if you use MySQLi use mysqli_set_charset('utf8'), if PDO you add charset=utf8 to the DSN...
In the same table when I insert data by HTML/PHP Forms I see some unrecognizable words in english something like cc2faa;(something like this) and Correct Hindi on Webpage.
For the large data we have a script that reads from txt files and insert the data in the table in this , I see characters like जाना in phpmyadmin but Hindi On webpage.
These are likely caused by the same problem as above: the PHP forms and the script connect to the database using the default encoding, probably latin1. Then they insert utf-8 encoded text, but since MySQL thinks you are using latin1, it encodes the text into utf-8 again, and inserts this doubly encoded text into the table.
So: PHP sends "जाना" to MySQL telling it's latin1, and MySQL goes and converts it to utf-8, resulting in "जाना". Later PHP asks MySQL return the value, and since the connection is again using latin1, MySQL takes "जाना" and decodes it to latin1. Then PHP pretends that this latin1 string is actually utf-8 and displays "जाना".
Again, the solution is setting the encoding of the connection to utf-8. And this depends on what you use to access the database.
If you need to export your data as Excel file, use the PHP class php-export-data by Eli Dickinson, http://github.com/elidickinson/php-export-data. It is pretty nifty and so far I had have no problems exporting weird character sets with it.

Mysql Database Name Restrictions

I am building a system where while the admin is installing it, one of the steps is to create a database (from the system). So my question is, how should I validate the database name? I found it can't be longer than 64 chars but is this the only restriction? I tested some db names with special characters in phpmyadmin which didn't give an error.
MySQL database naming restrictions:
Cannot be longer than 64 characters.
Cannot contain / \ or . characters.
Cannot contain characters that are not permitted in file names.
Cannot end with space characters.
More information here.
The Regex for this:
^[^\\/?%*:|\"<>.]{1,64}$

which database supports to insert vietnamese characters?

I tried inserting Vietnamese characters into MySQL database through my java program. It is getting inserted but certain characters are being inserted as junk. And while trying to retrieve, i'm getting the same junk values in place of some characters. Can anyone tel me what should be done? Is there a problem in MySQL or is there any DB that supports these characters?
Example of ‘junk’, and code?
In general you need to make sure:
your tables are created with UTF-8 collation on all text columns. This can be done at several levels: config default-character-set=utf8, db CREATE DATABASE ... DEFAULT CHARACTER SET utf8, table CREATE TABLE ... DEFAULT CHARACTER SET utf8, and column column VARCHAR(255) CHARACTER SET utf8. After the initial creation you can only do it by ALTER on the columns; changing the default character sets won't change the column.
that your connection to the database is in UTF-8 encoding, by specifying useUnicode=true and characterEncoding=UTF-8 properties in your connection string or properties. Ensure you have an up-to-date MySQL Connector as there have been grievous bugs here in the past.
that nothing else in your processing stream is mangling the characters before they get to the database connection, or on the way back out. Ensure you aren't using the default encoding anywhere because it is probably wrong. Setting the flag -Dfile.encoding=UTF-8 may help with that as a temporary workaround, but you don't want to rely on it.
(And if part of your testing involves printing to the terminal, be aware that the Windows command prompt won't be able to do anything with UTF-8 so you will definitely see junk there.)
Hi there no problem to store vietnamese characters, but check mysql FAQ first:
http://dev.mysql.com/doc/refman/5.0/en/faqs-cjk.html

Save Arabic text into MySQL database

I have this Arabic text: الخط الكوفي. When I try to save it in a MySQL database it doesn't save.
Is there any way to save it as the original text?
Make sure your MySQL instance and tables are set to take UTF-8, not latin1.
Section 9.1 of the manual covers this.
I'd take a look at the mysql docs for Character Sets. The default character set latin1 most likely doesn't handle the characters you're trying to use. You'll have to switch your tables over to UTF-8 if you want to store that properly.