Reputation: 8268
SO has the same question 'mysql change default table charset to database charset' asked before .I used the second answer to change my database default character set to utf-8 .
alter database mydatabase default character set utf8 collate utf8_general_ci;
But when I exported the database using phpMyAdmin
,though at the top I have
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
but for queries I have something like
--
-- Table structure for table `paras`
--
CREATE TABLE IF NOT EXISTS `paras` (
`p_id` int(11) NOT NULL AUTO_INCREMENT,
`para` text,
PRIMARY KEY (`p_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
where charset=latin1
.IMO it shouid be set to UTF-8
.Am I confusing something or what is the correct way?
Upvotes: 0
Views: 1849
Reputation: 522042
In MySQL individual columns have a actual charset setting. Anything else just has a default charset setting. This means if a charset is not explicitly specified for a column, the default charset of its table is used. If there is none, the default of the database it's in is used. If there is none, the server default is used. Each one of server, database and table has an individual default setting which overrides the next higher default.
What you did was simply set the default for the database, but your tables still have individual defaults set. You'll have to change it for each individual table.
Upvotes: 3