In-depth analysis of mysql-Based Multi-instance installation

Source: Internet
Author: User

I believe most people have encountered too many instances to install mysql. I believe most people only need to find a multi-instance installation tutorial and it will be easy to solve, but the more smooth the installation process, the more disturbing we are. Why do you know the purpose of each sentence when we follow the tutorial step by step? What should we do after an error occurs? Now I am going to show you how to install it.
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 following is my installation process, which is filled with various errors:

Copy codeCode: 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
-DMYSQL_DATADIR =/usr/local/mysql/data-DDEFAULT_CHARSET = utf8
-DDEFAULT_COLLATION = utf8_general_ci-DEXTRA_CHARSETS = all
-DENABLED_LOCAL_INFILE = 1
Make
Make install

This indicates that the installation of mysql source code has been completed. Now we need to initialize the user, that is, the most important part of multiple instances, pay attention to the result after command execution in each step in the future:Copy codeThe Code is as follows: 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

Copy codeThe Code is as follows: <SPAN style = "LINE-HEIGHT: 22px; FONT-FAMILY: Verdana,, Helvetica, sans-serif; FONT-SIZE: 14px "> scripts/mysql_install_db </SPAN> <BR style =" LINE-HEIGHT: 22px; FONT-FAMILY: Verdana,, Helvetica, sans-serif; FONT-SIZE: 14px "> <SPAN style =" LINE-HEIGHT: 22px; FONT-FAMILY: Verdana,, Helvetica, sans-serif; FONT-SIZE: 14px "> -- defaults-file =/usr/local/mysql/data_3308/my. cnf </SPAN> <BR style = "LINE-HEIGHT: 22px; FONT-FAMILY: Verdana,, Helvetica, sans-serif; FONT-SIZE: 14px "> <SPAN style =" LINE-HEIGHT: 22px; FONT-FAMILY: Verdana,, Helvetica, sans-serif; FONT-SIZE: 14px "> -- datadir =/usr/local/mysql/data_3308/</SPAN>

The above mysql_install_db command is used to initialize a new user. Pay attention to the result after command execution. The first execution result is as follows:Copy codeThe Code 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 complete

Here we can see that there has been an error. What is the cause? You should be able to understand it. You are so careless. This causes you to execute cmake again.
Then run the preceding command again. Until we see this result: the initialization is successful. Congratulations, you can perform the following operations.Copy codeThe Code is as follows: 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

At this time, he will generate some basic information such as mysql library and test Library 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.Copy codeThe Code is as follows: <SPAN style = "LINE-HEIGHT: 22px; FONT-FAMILY: Verdana,, Helvetica, sans-serif; FONT-SIZE: 14px "> mysqld_safe -- defaults-file =/usr/local/mysql/data_3307/my. cnf & </SPAN>

Copy codeThe Code is as follows: 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 pid 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 this way, we need the following command next time:Copy codeThe Code is as follows: 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 we can run the command to check the number of services we have activated, and then log on to the system to perform basic operations, 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,

Copy codeThe Code is as follows: root @ zhou:/usr/local/mysql/tmp # mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (111)

The cause of the error is that when I didn't specify the database server, it had a default startup plan, so we can see that it was still waiting for the server of mysql 3306.
Root @ zhou:/etc/init. d # mysql-h127.0.0.1-P3307

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.