Mysql multi-instance installation details first describe a scenario: My computer is a ubuntu system, and mysql has been automatically installed by apt-get before. This is one of the most common causes of errors. The installation process is filled with various errors: Java code 6. mkdir mysql 7. groupadd mysql 8. useradd-r-g mysql # make clean # rm-f CMakeCache.txt # rm-rf/etc/my. cnf 9. cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-scripts =/usr/local/mysql/data-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-dextra_sets char= all-ready = 1 make install the installation of mysql source code is complete, now we need to initialize the user, which is the most important part of multiple instances, Pay attention to the result of command execution in each step in the future: Java code cd/usr/local/mysql chown-R root: mysql. chown-R mysql: mysql data 11.cp support-files/my-medium.cnf/etc/my. cnf 12.cd/usr/local/mysql Java code scripts/mysql_install_db -- defaults-file =/usr/local/mysql/data_3308/my. cnf -- datadir =/usr/local/mysql/data_3308/the above mysql_install_db command is used to initialize a new user. Pay attention to the result after the command is executed. When Java code is executed for the first time, the result is as follows: root @ zhou: /usr/local/mysql # scripts/mysql_install_db -- defaults-file =/usr/local/mysql/data_3307/my. cnf -- datadir =/usr/local/mysql/data_3307/Installing MySQL system tables... 130107 10:25:47 [ERROR] COLLATION 'latin1 _ swedish_ci 'is not valid for character set 'utf8' 130107 10:25:47 [ERROR] Aborting 130107 10:25:47 [Note]/usr/local/mysql/bin/ mysqld: shutdown c Omplete can see the cause of the error. You can see it clearly. As a result, you re-Execute cmake and then re-execute the above command. Until we see this result: the initialization is successful. Congratulations, you can perform the following operations. Java code root @ zhou:/usr/local/mysql # mysql_install_db -- user = mysql -- defaults-file =/usr/local/mysql/data3307/my. cnf -- datadir =/usr/local/mysql/data3307/Installing MySQL system tables... OK Filling help tables... OK, then he will generate some basic information such as mysql database and test database in our data directory. By the way, you must pay attention to the fact that, when assigning permissions, mysql will not be able to read relevant files without caution. Java code mysqld_safe -- defaults-file =/usr/local/mysql/data_3307/my. cnf & 130107 13:35:36 [Note] Server socket created on IP: '0. 0.0.0 '. 130107 13:35:36 [ERROR]/usr/local/mysql/bin/mysqld: Can't find file :'. /mysql/host. frm' (errno: 13) 130107 13:35:36 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file :'. /mysql/host. frm' (errno: 13) 130107 13:35:36 mysqld_safe mysqld from pi D file/usr/local/mysql/data3307/mysql. pid ended the error is also obvious because we did not read the host. There are two ways to remedy frm permissions: one is to attach such permissions to mysql directly under the directory, and the other is to investigate why it is like that? The reason is that we did not add the -- user = mysql parameter during initialization, resulting in the full-city root permission of the generated file. In the next step, you need the following command: Java code root @ zhou: /usr/local/mysql # mysql_install_db -- user = mysql -- defaults-file =/usr/local/mysql/data3307/my. cnf -- datadir =/usr/local/mysql/data3307/-- user = mysql OK, then log on to the system to perform basic operations, including permissions, key tables, and replication. After starting three mysql servers, I found that I could only log on to the service above 3306, but I couldn't log on. When I killed 3307 3306, an ERROR occurred while logging on to mysql. the Java code root @ zhou:/usr/local/mysql/tmp # mysql ERROR 2002 (HY000 ): can't connect to local MySQL server through socket '/tmp/mysql. sock '(111) Error cause: when no database server is specified, it has a default startup plan, so we can see that it is still waiting for the server of mysql 3306. Java code root @ zhou:/etc/init. d # mysql-h127.0.0.1-P3307