VARCHAR automatically changes to VARBINARY I am new to MySQL. When I declare a column as VARCHAR, why does it automatically change to VARBINARY? How should I avoid this? 



Database changed                                                       
mysql&gt; CREATE TABLE sync(
-&gt; vlan_id INT NOT NULL,
-&gt; vlan_name VARCHAR(90) NOT NULL,
-&gt; vlan_description VARCHAR(100) NOT NULL,
-&gt; PRIMARY KEY(vlan_id)
-&gt; );


Database changed
mysql&gt; SHOW CREATE TABLE sync;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                             |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| sync  | CREATE TABLE `sync` (
  `vlan_id` int(11) NOT NULL,
  `vlan_name` varbinary(90) NOT NULL,
  `vlan_description` varbinary(100) NOT NULL,
  PRIMARY KEY (`vlan_id`)
) ENGINE=InnoDB DEFAULT CHARSET=binary |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql&gt;
I'm guessing you have binary as your default character set for the server and/or for the database. You probably want to change this to prevent the same thing happening next time you create a table. 

You can check by running: SHOW VARIABLES LIKE 'character_set_server'; and SHOW CREATE DATABASE the_database_name;

If the database doesn't have a character set, then the server character set will be used.

You can change the database character set with a command like:

ALTER DATABASE the_database_name CHARACTER SET = 'utf8';


The server character set can be set with a command like:

SET character_set_server = 'utf8';


(Use SET GLOBAL ... for the setting to be made outside of the current session. Or you can set this in your config file so it survives a restart.)