CentOS6.7 installmysql5.7.18


  1,  Unzip to/usr/local Catalog

    # tar -zxvf mysql-5.7.18-linux-glibc2.5-i686.tar.gz -C /usr/local

  2,  mysql-5.7.18-linux-glibc2.5-i686 Rename folder tomysql

    # cd /usr/local

    # mv mysql-5.7.18-linux-glibc2.5-i686/ mysql

  3,  Newly buildmysql User group andmysql user

    # groupadd mysql

    # useradd -r -g mysql mysql

  4,  New data directory

    # cd /usr/local/mysql

    # mkdir data

  5,  Change owner and authorization755

    # cd /usr/local

    # chown -R mysql:mysql mysql/

    # chmod -R 755 mysql/

  6,  Initializationmysqld

    # cd /usr/local/mysql

    # ./bin/mysqld --user=mysql --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data --initialize


     Recordroot Initial password for: GjlI08>p4kDw

  7,  takemysqld Add as service, And start it.

    # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

     establishmysql Default profile/etc/my.cnf, And add content in the picture


    # vim /etc/my.cnf

     Save and exitmy.cnf, start-upmysqld

    # service mysqld start

     The following message appears to indicate successful startup


     Seemysql Whether to start successfully

    # ps -ef|grep mysql

     The following message appears to indicate successful startup


     You can also checkmysqld State

    # service mysqld status


  8,  Sign inmysql And modifyroot Password

    # cd /usr/local/mysql

    # ./bin/mysql -uroot –p

     Enter initial password, step6 Intermediate generation, The following message appears to indicate successful login


     modifyroot Password

    mysql> SET PASSWORD = PASSWORD('123456');


     Initial login not modifiedroot Password, The following error prompts will appear when operating the database, Then it needs to be modifiedroot User's password

      ERROR 1820 (HY000): You must reset your password using ALTER USER
statement before executing this statement.

  9,  Set upmysql Remote accessible( The premise is that the firewall must be closed,chkconfig iptables off: Set auto start to off,service
iptables stop: Turn off firewall)

     Log in first.mysql

    mysql> use mysql

    mysql> update user set host = '' where user = 'root';

    mysql> FLUSH PRIVILEGES; Remote access to localmysql Remoteip, If you want to be arbitraryip Local accessmysql, Then just192.168.0.4 change into% that will do

    mysql> update user set host = '%' where user = 'root';

mysql Master slave replication

  windows uppermysql domaster,linux uppermysql doslave,mysql Version is5.7.18;windows Ofip by192.168.0.4,linux Ofip by192.168.0.223

  1,master Upper openingbinlog Journal

          staymysql Ofhome Directory Findmy.ini file( New if not), The configuration is as follows
[mysqld] # set basedir to your installation path basedir=D:\\mysql-5.7.18 #
set datadir to the location of your data directory datadir=D:\\mysql-5.7.18
\\data port= 3306

log-bin = mysql-bin #[ Must] Enable binary logging server-id = 4 #[ Must] Server uniqueID, The default is1, Better takeip After3 position
expire-logs-days = 7 # Only keep7 Binary log for days, In case the disk is full of logs binlog-ignore-db = mysql # Databases not backed up
binlog-ignore-db = information_schema binlog-ignore-db = performation_schema
binlog-ignore-db = sys binlog-do-db=mybatis # Database name to be copied
          testlog_bin Open successfully or not

         mysql> show variables like '%log_bin%';

          Appear below,log_bin byON It means the opening is successful,OFF Indicates open failed


  2,master Set up backup account in database of
:backup Username,% Represents any remote address, The password is as follows1234 Of any remote addressbackup Can be connectedmaster Host

    mysql> grant replication slave on *.* to 'backup'@'%' identified by '1234';

    mysql> use mysql

    mysql> select user,authentication_string,host from user;

     You can see the backup account we just created:


  3, Copy data

          restartMySQL Service and set read lock

      net stop MySQL

      net start MySQL

       Sign inmysql

           mysql> flush tables with read lock;

     Read lock means read only, Cannot update, For a consistent snapshot

     View the current binary log name and offset values on the primary server   

    mysql> show master status \G


     The process of copying is as follows:


    File Represents the log that implements the replication function, That is, in the figure aboveBinary
log;Position Expressbinlog The offset of the log file will be synchronized to theslave in, Before the offset, we need to import it manually

         frommaster Derived data, Then import toslave in

                 Open another command window, usemysqldump Command to export data


       taked:\a.txt copy toslave upper, Then import tomysql Database,slave Uppermybatis Create first if database does not exist, Then import


       Export ismysqldump, Import ismysql

  4, To configureslave(

         slave yeslinux Environmental Science,mysql The configuration file for is/etc/my.cnf, New if it doesn't exist, Match with the following
[mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/tmp/
mysql.sock user=mysql port=3306 log-bin=mysql-bin server-id=223
         restartslave data base

      # service mysqld restart

         Sign inslave data base, And make the following settings

      mysql> stop slave;

      mysql> change master to






                 Meaning of each parameter:

                master_host TheIP address

                master_user Remote login for replicationmaster Ofmysql Users, Steps in2 Set up

                master_password Remote login for replicationmaster Ofmysql Face, Steps in2 Set up

                master_log_file Implementing replicatedbinlog log file Steps in3 In the red frame

                master_log_pos Implementing replicatedbinlog Offset of log file Steps in3 In the red frame

      mysql> start slave;

     Seeslave Status of slave

                mysql> show slave status \G



       If the values of the two items marked in the figure areYes, Expressslave Set up successfully

  5, Turn off the read lock of the primary database

         mysql> unlock tables;

  6, test

     If there's no problem ahead, thatmaster All data operations on will be synchronized to theslave upper

Document address

   Click here.