Mysql multi-instance installation details _ MySQL

Source: Internet
Author: User
Explanation of mysql multi-instance installation bitsCN.com

Detailed description of mysql multi-instance installation

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

-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:

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 command execution,

Java code

For the first time, my execution 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 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.

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

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.

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 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 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 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,

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)

Cause of error: when the database server is not 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

BitsCN.com

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.