First, download mysql5.7
http://mirrors.sohu.com/mysql/MySQL-5.7/
Linux Downloads:
Input command: wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
Second, the establishment of users, as well as the MySQL directory
1. Set up a MySQL group
Input command: Groupadd MySQL
2. Build MySQL user and put it into MySQL group
Input command: useradd-r-g MySQL MySQL
3. Set password for MySQL user
Input command: passwd MySQL
Third, decompression MySQL
1. Move the downloaded MySQL package to the Linux virtual machine
2. Copy the tar package to the/usr/local directory
Input command: mv/software/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz/usr/local
3. Decompression
Input command: cd/usr/local
Input command: Tar xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
4. Change the extracted file name to MySQL
Input command: MV mysql-5.7.17-linux-glibc2.5-x86_64 MySQL
Iv. configuration-related boot configuration files
1. Copy my_default.cnf to/ETC/MY.CNF (automatically read when MySQL starts)
Input command: CP my-default.cnf/etc/my.cnf
2, solve garbled problem
Input command: VI/ETC/MY.CNF
Change:
[MySQL]
Default-character-set=utf8
[Mysqld]
Default-storage-engine=innodb
Character_set_server=utf8
3, copy Mysql.server to/etc/init.d/
Input command: CP Mysql.server/etc/init.d/mysql
4, modify the/etc/init.d/mysql parameter, give 2 directory location
Input command: Vi/etc/init.d/mysql
Change: Basedir=/usr/local/mysql
Datadir=/usr/local/mysql/data
5, to the directory/usr/local/mysql change owner
Input command: Chown-r mysql:mysql/usr/local/mysql/
V. Initialize the MySQL database
1. Initialize the database
The first thing to do is to go to the Mysql/bin directory
Old version of the command: mysql_install_db
New version of the command:./mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data
Generate a data directory that represents the successful initialization of the database
2. Encrypt the database
Input command:./mysql_ssl_rsa_setup--datadir=/usr/local/mysql/data
3. Start MySQL
Input command:./mysqld_safe--user=mysql &
& symbols: Throw the current process to the background
Vi. entering the client
1. Login
Input command:./mysql-uroot-p
and enter your temporary password.
2. Change the password
Input command: Set Password=password (' Your password ');
Vii. Windows remote access to Linux virtual machine MySQL
1, first to shut down the firewall, so that window can connect to the
Input command: Systemctl stop Firewalld.service
2. Authorization to Window
Input command: Grant all privileges on * * to [email protected] '% ' identified by ' 123456 ';
3. Window Remote Connection
Input command: Mysql–hip address-uroot-p123456
Eight, set the boot automatically start the MySQL service
1. Add service MySQL
Input command: chkconfig--add MySQL
2. Set up service start-up
Input command: Chkconfig MySQL on
Ix. Setting the PATH environment variable
Input command: Vi/etc/profile
Set environment variables: Export path= $JAVA _home/bin:/usr/local/mysql/bin: $PATH
After configuring the environment variables, we will not have to go to the/usr/local/mysql/bin directory to log in, now you can log in any directory MySQL
Ten, complete
So our MySQL database is configured.
Master-slave replication
1. Modify Master server Master:
#vi/etc/my.cnf
[Mysqld]
Log-bin=mysql-bin//[must] enable binary logging
Server-id=1//[can be the same as IP last] server unique ID, default is 1, usually take IP last paragraph
2. Modify the slave from the server:
#vi/etc/my.cnf
[Mysqld]
Log-bin=mysql-bin//[not required] enable binary logging
server-id=2//[can be the same as IP last] server unique ID, default is 1, usually take IP last paragraph
3./etc/init.d/mysql restart//Restart
4. Establish an account on the primary server and authorize slave:
Mysql>use MySQL//use
SELECT * FROM user\g;//view users
Grant Replication Slave on * * to ' mysync ' @ ' 10.101.110.% ' identified by ' root ';//set so IP can be accessed or write fixed IP
Flush privileges;//Refresh
Mysql-umysync-p//Enter MySQL
Mysql-uroot-p//Enter root
Mysql-uroot-p//View status
5. Operations from the server
Use MySQL; Use
SELECT * FROM user\g;//view users
Stop slave; Stop the master-slave Replication Service
Show slave status\g;//check status OK
Slave_io_running:yes
Slave_sql_running:yes
Show OK;
6. If the virtual machine is cloned, you need to do the following
Locate auto.cnf//see auto.cnf in that position
Enter AUTO.CNF
[Auto]
Server-uuid=65936c91-b2db-11e7-89db-000c2916dc12
The last change;
MySQL restart//restart
Show slave status\g;//check status OK
Slave_io_running:yes
Slave_sql_running:yes
Show OK;
mysql5.7 installation and master-slave replication