Recently read the O ' Reiliy series of "high-availability MySQL", naturally without the master-slave (master-slave) configuration and scale-related content. Master-slave this thing, in many companies are standard, the development of the basic daily use, encountered a lot of problems naturally (such as the Master never sync, master down), but the operation of limited permissions. Some things, only their own to see, do, to really know what the principle is, but also better to grasp.
This article is the first reading note for high-availability MySQL, which mainly records the installation process of the compressed version of MySQLin the Windows environment (which is no longer mentioned in the installation-based idiot installation process).
1. Download the compressed version of MySQL from the official website
is: http://www.mysql.com/downloads/
Now that Oracle takes over MySQL, it seems like all the resources need to have an Oracle account to download, and for those who are accustomed to click-to-download, they are really not used to it.
The file I downloaded is:mysql-advanced-5.6.21-win32.zip
This version of MySQL after decompression is very large, about 1.6G, the impression of the previous installation of the MySQL 5.1 version of all Files + database files of several projects, but also just 700M
The folder after decompression contains approximately the following subdirectories:
which
Bin directory -a variety of executable programs that primarily store MySQL
Data directory -database files and index files, etc.
Mysql-test -There are a lot of well-written test scripts
sql-bench -scripts for MySQL benchmark benchmarks
Bin, data, include, LIB, scripts directories, etc. are important to MySQL's normal operation, if not necessary, do not move the contents of these directories
About the selection of the Unzip directory:
Many people like to extract MySQL into the Program Files folder, I do not recommend this, because: Program Files folder itself with a space, in many cases, problems may occur. For example, some programs may take spaces as the end of a directory. The recommended decompression directory is: d:/mysql/this form, or in other directories, such as D:/lamp/mysql, where it is not important.
2. Configure Environment Variables
Open the System environment variable, append under the PATH variable (note that append is not overwritten) the MySQL Bin directory:
The blue section should be the full path to your bin directory. Once configured, save and close the System Variables window.
3. Configure the MySQL configuration file My.ini
The normal installation version of MySQL will generate 4 different configuration ini profiles in the root directory of MySQL:
My-small.ini
My-medium.ini
My-large.ini
My-huge.ini
These profiles are roughly the default configuration given by the size of the database, and you can copy and generate the actual My.ini configuration file according to your own situation. Some versions also generate only InnoDB configuration files, which are not mentioned here.
After this compressed version of MySQL decompression, there is only one default profile in the root directory:my-default.ini. And when turned on, the configuration options are extremely simple:
In addition, there is no other (Khan).
Our configuration begins with this:
(1). Configure Basedir
Basedir refers to the root directory of MYSQL, so it should be: Basedir = D:\MYSQL
(2). Configure Data
The data directory is the directory where the files and indexes are stored, and you can specify directories other than the MySQL directory as storage directories, but be aware of permissions issues. My configuration is: DataDir = D:\MYSQL\data
(3). Configuring ports
General MySQL service uses 3306 port, if the port is accounted for, can replace other ports
(4). More Configuration
Set the client mode character: Default-character-set=utf8, on this issue, there will be a post devoted to it.
Table default storage citation: Default-storage-engine=innodb. Here by the way, MySQL compared to the old release, the default storage engine is MyISAM, the newer version is the default InnoDB storage engine (which version, I do not remember: D, can be seen through the changelog know)
For more configuration, check out the MySQL manual.
4. Install the MySQL service and start
Execute mysqld–install MySQL in the bin directory of MySQL (please remember to run cmd as Administrator)
Start MySQL service: net start MySQL(or right-click on the service->mysql, right-click Computer)
5. Modify the MySQL user account
In this case, you should be able to connect to MySQL via command line at CMD.
After MySQL is installed by default, the root user and an anonymous user are generated, it is recommended to change the root account password and delete the anonymous user, the following actions:
Use test; Select Host,userfromuser;
(1) To delete an anonymous user :
Delete from User where User =";
(2) To change the root account password :
Update User Set Password=Password ('123456whereUser=' root ';
(3) add MySQL remote connection permissions
Grant All Privileges on *. * to [Email protected] ' % ' by ' 123456 ';
(4) Refresh Permissions
privileges;
The user table is a built-in table for MySQL that records information such as user permissions, passwords, and so on. The primary key for this table is Host+user, which can be seen by the show Index command:
The _priv ending field is the MySQL operation permission for the corresponding account, and Filed-type is the enum
At this point, the configuration of MySQL is basically completed, the subsequent will continue to paste the contents of the MySQL master-slave configuration. This is where the high-availability MySQL journey begins.
"High availability MySQL" Reading notes 1–windows Environment compressed version MySQL installation