Mysql multi-instance installation details _ MySQL

Source: Internet
Author: User
Mysql multi-instance installation details bitsCN.com

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:
  1. 6. mkdir mysql
  2. 7. groupadd mysql
  3. 8. useradd-r-g mysql
  4. # Make clean
  5. # Rm-f CMakeCache.txt
  6. # Rm-rf/etc/my. cnf
  7. 9. cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql
  8. -DMYSQL_DATADIR =/usr/local/mysql/data-DDEFAULT_CHARSET = utf8
  9. -DDEFAULT_COLLATION = utf8_general_ci-DEXTRA_CHARSETS = all
  10. -DENABLED_LOCAL_INFILE = 1
  11. Make
  12. Make install
This indicates that the mysql source code installation has been completed, and now it is necessary to initialize the user, that is, the most important part of multiple instances. pay attention to the result after the command is executed in every step of the future:
  1. Cd/usr/local/mysql
  2. Chown-R root: mysql.
  3. Chown-R mysql: mysql data
  4. 11. cp support-files/my-medium.cnf/etc/my. cnf
  5. 12. cd/usr/local/mysql
  1. 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,
  1. For the first time, my execution result is as follows:
  2. Root @ zhou:/usr/local/mysql # scripts/mysql_install_db -- defaults-file =/usr/local/mysql/data_3307/my. cnf -- datadir =/usr/local/mysql/data_3307/
  3. Installing MySQL system tables...
  4. 130107 10:25:47 [ERROR] COLLATION 'latin1 _ swedish_ci 'is not valid for character set 'utf8'
  5. 130107 10:25:47 [ERROR] Aborting
  6. 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.
  1. Root @ zhou:/usr/local/mysql # mysql_install_db -- user = mysql -- defaults-file =/usr/local/mysql/data3307/my. cnf -- datadir =/usr/local/mysql/data3307/
  2. Installing MySQL system tables...
  3. OK
  4. Filling help tables...
  5. 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 should pay attention to the permission allocation. if you are not careful about mysql, you will not be able to read the relevant files.
  1. Mysqld_safe -- defaults-file =/usr/local/mysql/data_3307/my. cnf &
  2. 130107 13:35:36 [Note] Server socket created on IP: '0. 0.0.0 '.
  3. 130107 13:35:36 [ERROR]/usr/local/mysql/bin/mysqld: Can't find file: './mysql/host. frm' (errno: 13)
  4. 130107 13:35:36 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host. frm' (errno: 13)
  5. 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:
  1. 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,
  1. Root @ zhou:/usr/local/mysql/tmp # mysql
  2. 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.
  1. 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.