很久以前搭建过MySQL多实例,记得当时很顺利,呵呵!今天公司因为业务需要,我再一次搭建多实例.安装完MySQL后,初始化两个实例时,出现如下报错:

      150915  1:10:36 [ERROR] COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'latin1'
      150915  1:10:36 [ERROR] Aborting

     乍一看,是字符编码问题,着实在my.cnf配置文件上面设置了字符编码如下:       

       [client]

         default-character-set = utf8

       [mysqld]
         character_set_server = utf8

     保存退出,再试尝试初始化,又出现如下错误:

         150915  1:53:38 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
         150915  1:53:38 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
         150915  1:53:38 [Note] Server socket created on IP: '0.0.0.0'.
         150915  1:53:38 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

     通过一通查找资料,再分析上面的这两行,如下:

         150915  1:53:38 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
         150915  1:53:38 [Note]   - '0.0.0.0' resolves to '0.0.0.0';

     这时突然想到,这台机器以前用来测试项目时,修改过hosts文件。于是打开hosts文件删除了添加的hosts映射,留下默认的,保存退出。

     一定还会有人问我上面的这个错误怎么不解决,如下:

          150915  1:53:38 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

     这个问题,重新初始化一下系统数据库,就可以了。

     呵呵,初始化成功,启动成功!!!!