Deep analytic _mysql based on Mysql multi-instance installation

Source: Internet
Author: User

Believe that most people have encountered too many instances of installing MySQL bar, I believe most people just find a multiple-instance installation tutorial will be easy to handle, but the more smooth installation process let us uneasy, why, when we follow the tutorial step-by-step, you know the purpose of each sentence? What should we do after the error occurs? Now I show you my installation process, a variety of entanglements, various errors.
First, a scene: My computer is an Ubuntu system, before the apt-get automatically installed MySQL. This is one of the most common causes of errors.
Here's my installation process, which is full of bugs:

Copy Code code as follows:

6.mkdir MySQL
7.groupadd MySQL
8.useradd-r-G MySQL 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 means that our MySQL source installation has been completed, and now to do is to initialize the user, that is, the most important one in many instances, every step in the future should pay attention to the results of the implementation of the command:
Copy Code code 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 Code code as follows:

<span style= "LINE-HEIGHT:22PX; Font-family:verdana, XXFarEastFont-Arial, Helvetica, Sans-serif; font-size:14px ">scripts/mysql_install_db </span><br style=" LINE-HEIGHT:22PX; Font-family:verdana, XXFarEastFont-Arial, Helvetica, Sans-serif; font-size:14px "><span style=" LINE-HEIGHT:22PX; Font-family:verdana, XXFarEastFont-Arial, Helvetica, Sans-serif; font-size:14px ">--defaults-file=/usr/local/mysql/data_3308/my.cnf </span><br style=" line-height:22px ; Font-family:verdana, XXFarEastFont-Arial, Helvetica, Sans-serif; font-size:14px "><span style=" LINE-HEIGHT:22PX; Font-family:verdana, XXFarEastFont-Arial, Helvetica, Sans-serif; Font-size:14px ">--datadir=/usr/local/mysql/data_3308/</SPAN>

The above mysql_install_db command is to initialize the new user. Notice the result of the command execution, and the first time I do this:
Copy Code code 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 a for CHARACTER SET ' UTF8 '
130107 10:25:47 [ERROR] Aborting
130107 10:25:47 [note]/usr/local/mysql/bin/mysqld:shutdown complete

Here you can see that there has been a mistake, the reason is what, we should be able to see that they are too sloppy. Causing a cmake to be performed again.
And then the above command is renewed. Until we see the result: The initialization is successful, congratulations you can do the following.
Copy Code code 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 point he will generate some basic information such as MySQL Library and test library in our data directory.
To be sure to pay attention to, the allocation of permissions, inadvertently MySQL can not read the rights of the relevant documents.
Copy Code code as follows:

<span style= "LINE-HEIGHT:22PX; Font-family:verdana, XXFarEastFont-Arial, Helvetica, Sans-serif; font-size:14px ">mysqld_safe--defaults-file=/usr/local/mysql/data_3307/my.cnf &</SPAN>

Copy Code code 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 here is also obvious because we did not read the host. frm, the remedy of two kinds: one is directly to the directory to the MySQL attached to the permissions, the second is to investigate the reason why it? The reason is that we did not add--user=mysql this parameter when initializing, which caused the file to be generated by the city root authority. It's a good thing to do. We'll need the order the next time we do it:
Copy Code code 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, at this time we can through the command to see the number of services we opened, and then log on to carry out basic operations, permissions, key table Ah, replication Ah, and so on.

Here started three MySQL server, found that can only log on to 3306 of the above services to go, while the other is unable to login, when I killed 3307 3306, login MySQL is indeed a mistake,

Copy Code code as follows:

root@zhou:/usr/local/mysql/tmp# MySQL
ERROR 2002 (HY000): Can ' t connect to the local MySQL server through socket '/tmp/mysql.sock ' (111)

The reason for the error here is that when I do not specify that database server is it has a default startup plan, so here you can see that it is still waiting for the MySQL 3306 server.
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.