Put the my.cnf on first.
[MYSQLD_MULTI]MYSQLD =/usr/bin/mysqld_safemysqladmin =/usr/bin/mysqladminuser =rootpassword =123456[mysqld2]socket =/tmp/mysql.sock2port = 3306pid-file =/home/mysql/mysql2/hostname.pid2datadir =/home/mysql/mysql2user =mysqllog-bin =/home/mysql/mysql2/binloglog-error =/home/log/mysql2.log [mysqld3]socket =/tmp/mysql.sock3port = 3307pid-file =/ Home/mysql/mysql3/hostname.pid3datadir =/home/mysql/mysql3user =mysqllog-bin =/home/mysql/mysql3/binloglog-error = /home/log/mysql3.log
MY.CNF parameter Resolution
Note the location of the mysqld and Mysqladmin, which is the location of the installed MySQL, with Mysqld_safe and mysqladmin in the directory.
The usefulness of user and password for the time being unclear
[Mysqld2] and [mysqld3] can modify the number, add more instances, while the digital 2,3 is also the glyph of the Open instance
The socket and port define the credentials to enter a different DB instance, and then the login will use
Pid-file function is unknown, but different instances of the directory are not the same
DataDir is the location of data storage, preferably in a directory with large storage space
User general default MySQL [guessing is the system account used when the database is automatically operated, such as reading and writing data, etc.]
Log-bin log-error Database change information file, database error information file, when the master from the main database or the primary copy of the need to use the Log-bin
Log-bin log-error datadir pid-file sockets need to be unique in each instance configuration, that is, different
DataDir Log-error Log-bin and other directories need to create their own manually [if not present], and assign permissions to user[this is MySQL]
DataDir need to call mysql_install_db--datadir= '/Your path in the terminal '--user= ' your user [here is MySQL] '
If mysql_instal_db is not found then it is possible that MySQL is not added to the environment variable, you need to add the MySQL installation path to the environment variable, using the Export statement, the tool with Mysqld_multi Mysqld_safe in the same directory
MySQL installation path, depends on the respective machine, is generally/usr/bin or/usr/local/mysql/bin, as long as the directory can find mysql_install_db,mysqld_safe these files, Basically, you can determine the path to MySQL.
Open instance
Configure the MY.CNF to add the data files of each instance and give user[here is MySQL] directory permissions [by chown-r username. Group name FileName], confirm that the port is not occupied, you should be able to open the instance
Open instance used to: Mysqld_mutil
The direct Input command allows you to view specific usage,
The main use of the Mysqld_mutil-start [ID] [ID] can be 2,3 (open [mysqld2] and [mysqld3]) 2 ([mysqld2]) 2-5 (open [mysqld2] to [MYSQ] LD5])
The previous identifier is used here, which allows you to start a batch or a single instance.
Mysqld_mutil Report This command is used to view the status of each instance, if you see two lines, it is started, English is very well understood
MySQL server from Group:mysqld2 is running
MySQL server from GROUP:MYSQLD3 is running
If everything is OK, you can see Log-bin log-error sock and other files are out, and the corresponding port is also mysqld occupied, port view to use the netstat command
Multi-instance open, login need to use mysql-u[user name]-p[password, you can not enter wait for system reminder input]-s[sock configuration file sock file]-p[port number] (note case [] to remove)
Ex-> mysql-uroot-p-s/tmp/mysql.sock2-p3306
Because it is more than one instance, it is not possible to mysql-u-p as a single instance, requiring a symbolic distinction, that is, a previously defined sock or a specified port
Then enter the password, you may find that no matter what account number, password, can not access the database, or enter after no various permissions,
This time you need to initialize the root account for the first time Mysqladmin-s[sock] password "to an initial password ~" should be able to use the root account login
Simple user actions
After the operation, such as
Add databases create database [DB name];
Show all databases show databases;
Use a database using [database name];
Create new account create user ' username ' @ ' host ' identified by ' password '
(host is the allowed client access identity, can be specified IP address, localhost only local,% [% means all access addresses accepted], or 192.168.1.% such an IP segment)
User Password user name host three a primary key the data can be viewed in the Mysql.user table, so you can also directly manipulate the Mysql.user table to add users (specific online there-simply nonsense)
Create new account and give permission-this is much better than a simple new account grant Select,delete,update,insert on * * to ' user name ' @ ' host ' identified by ' key '
Where select,delete such as permissions, other similar permissions such as all privileges
*. * indicates that the permission object is a database, and of course you can also specify that the permission object is a single database, such as test.*, that the user can only view the test table [it is unclear why it must be test.* rather than direct test]
Host is the same as before, if access to all addresses is accepted, then use%
After setting permissions, remember to flush privileges; Otherwise, you may not be able to use your account
Delete User: Delete from mysql.user where user = ' user name '
This table was used when the results were deleted.
After setting permissions, remember to flush privileges;
-master-slave-Master-slave server Setup [wall to go]
http://www.mike.org.cn/articles/mysql-master-slave-sync-conf-detail/
MySQL single version multi-instance MYSQL55