CentOS 7.2 Yum Compile install Mysql 5.6_mysql

Source: Internet
Author: User
Tags flush reserved centos

This example for you to share the CentOS 7.2 Yum installation mysql5.6 method, for your reference, the specific contents are as follows

Configure CentOS Sclo Source

[3] Add CentOS Sclo Software collections Repository.
[root@linuxprobe~]# yum-y Install CENTOS-RELEASE-SCL-RH CENTOS-RELEASE-SCL
# Set [priority=10]
[ root@linuxprobe~]# sed-i-E "s/\]$/\]\npriority=10/g"/etc/yum.repos.d/centos-sclo-scl.repo
[root@linuxprobe~] # Sed-i-E "s/\]$/\]\npriority=10/g"/etc/yum.repos.d/centos-sclo-scl-rh.repo
# for another way, change to [enabled= 0] and use it only when needed
[root@linuxprobe~]# sed-i-E "s/enabled=1/enabled=0/g"/etc/yum.repos.d/centos-sclo-s Cl.repo
[ROOT@DLP ~]# sed-i-E "s/enabled=1/enabled=0/g"/etc/yum.repos.d/centos-sclo-scl-rh.repo

Yum install MySQL

# install MySQL
[root@linuxprobe~]# yum--enablerepo=centos-sclo-rh-y install rh-mysql56-mysql-server
# Load Environment variables
[root@linuxprobe ~]# SCL enable RH-MYSQL56 bash
[Root@linuxprobe ~]# mysql-v 
mysql Ver 14.14 distrib 5.6.26, for Linux (x86_64) using Editline wrapper
[Root@linu Xprobe ~]# which MySQL 
/opt/rh/rh-mysql56/root/usr/bin/mysql
# set MySQL boot from root@linuxprobe
~]# profile.d/rh-mysql56.sh
#!/bin/bash
source/opt/rh/rh-mysql56/enable
export x_scls= ' SCL enable Rh-mysql56 ' echo $X _scls ' "


[4] Enable MySQL 5.6 and Configure initial settings. [Root@linuxprobe ~]# vi/etc/opt/rh/rh-mysql56/my.cnf.d/mysql-server.cnf # Add follows within [mysqld] section [mysqld] C Haracter-set-server=utf8 [Root@linuxprobe ~]# systemctl start rh-mysql56-mysqld [root@linuxprobe ~]# systemctl Enable  rh-mysql56-mysqld [Root@linuxprobe ~]# mysql_secure_installation note:running All PARTS The This SCRIPT are recommended for All MySQL SERVERS in PRODUCTION use!
Please READ each step carefully! In order to log into MySQL to secure it, we'll need the current password for the root user. If you ' ve just installed MySQL, and you haven ' t set the root password yet, the password'll be blank, so you should just
Press ENTER here.
Enter current password for root (enter to none): OK, successfully used password, moving on ...
Setting The root password ensures that nobody can log into the MySQL root user without the proper authorisation. # set root password set root password? [y/n] Y New password:re-enter NEW Password:password Updated successfully!
 Reloading privilege tables. ...
success! By default, a MySQL installation has the anonymous user, allowing anyone to log into MySQL without have to have a user AC Count created for them. This is intended only for testing, and to make the installation go a bit smoother.
You are should remove them before moving into a production environment. # Remove anonymous users remove anonymous users? [y/n] Y ...
success! Normally, Root should only is allowed to connect from ' localhost '.
This ensures is someone cannot guess at the root password from the network. # Disallow root login remotely disallow root login remotely? [y/n] Y ...
success! By default, the MySQL comes with a database named ' test ' that anyone can access.
This is also intended only for testing, and should are removed before into a moving production. # Remove test Database Remove test database and access to it? [y/n]-dropping test database ...
 success! -Removing privileges On test Database ...

success!
Reloading the privilege tables would ensure this all changes made so far would take effect. # Reload Privilege Tables Reload privilege tables now? [y/n] Y ...
success!
Cleaning up ... All done!
If you have ' ve completed all of the above steps, your MySQL installation should now be secure.


 The for using mysql!
[Root@linuxprobe ~]# mysql-u root-p Enter password:welcome to the MySQL monitor. Commands End With;
or \g. Your MySQL connection ID is server version:5.6.26 mysql Community server (GPL) Copyright (c), 2015, Oracle and/o R its affiliates.

All rights reserved. Oracle is a registered trademark to Oracle Corporation and/or its affiliates.
The other names may is trademarks of their respective owners. Type ' help, ' or ' \h ' for help.
Type ' \c ' to clear the current input statement. 
Mysql> select User,host,password from Mysql.user; +------+-----------+-------------------------------------------+
| user | Host |
password | +------+-----------+-------------------------------------------+
| Root | localhost | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 | | Root | 127.0.0.1 | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 | | Root | :: 1 |
*E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 | +------+-----------+-------------------------------------------+ 3 rows in Set (0.00 sec) mysql>show databases; +--------------------+
|
Database | +--------------------+
| Information_schema | | MySQL | |
Performance_schema |


 +--------------------+ 3 rows in Set (0.00 sec) mysql> Exit Bye

Open firewall

[Root@linuxprobe ~]# firewall-cmd–add-service=mysql–permanent 
Success 
[Root@linuxprobe ~]# Reload 
Success

Also use Yum to install MySQL on vdevops.org above, installation steps refer to above

MySQL Master

Master end:linuxprobe

[root@linuxprobe~]# vi/etc/opt/rh/rh-mysql56/my.cnf.d/mysql-server.cnf
[mysqld]
# Add follows in [mysqld] Section:get binary Logs
log-bin=mysql-bin
# define UNIQ server ID
server-id=101
[Root@linuxprobe ~]# Mysql-u root-p 
Enter Password: 
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL connection ID is 2
server version:5.6.26-log mysql Community server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark to Oracle Corporation and/or its
affiliates. The other names may is trademarks of their respective
owners.
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
mysql> grant replication Slave on *.* to replica@ '% ' identified by ' password ';
Query OK, 0 rows affected (0.07 sec)
mysql> flush privileges; 
Query OK, 0 rows Affected (0.00 sec)
mysql> exit
Bye

Open firewall

[Root@linuxprobe ~]# firewall-cmd–add-service=mysql–permanent 
Success 
[Root@linuxprobe ~]# Reload 
Success

slave end:vdevops

[root@vdevops~]# vi/etc/opt/rh/rh-mysql56/my.cnf.d/mysql-server.cnf
[mysqld]
# Add follows in [mysqld] Section:get binary Logs
log-bin=mysql-bin
# define server ID (different one from Master Host)
server-id=1
# Read Only
read_only=1
# define own hostname
Report-host=node01.srv.world
[ root@vdevops~]# systemctl Restart Rh-mysql56-mysqld

Master end: backing up a database

[Root@linuxprobe ~]# mysql-u root-p Enter password:welcome to the MySQL monitor. Commands End With;
or \g. Your MySQL Connection ID is 3 server version:5.6.26-log mysql Community Server (GPL) Copyright (c), 2015, Oracle and /or its affiliates.
All rights reserved. Oracle is a registered trademark to Oracle Corporation and/or its affiliates.
The other names may is trademarks of their respective owners. Type ' help, ' or ' \h ' for help.
Type ' \c ' to clear the current input statement. Mysql> flush tables with read lock; # Lock Table Query OK, 0 rows affected (0.01 sec) mysql> Show master status; #记住file的数值和position的值 +------------------+----------+--------------+------------------+-------------------+ | File | Position | binlog_do_db | binlog_ignore_db |
Executed_gtid_set | +------------------+----------+--------------+------------------+-------------------+
|  mysql-bin.000001 |    400 |     |     |
| +------------------+----------+--------------+------------------+-------------------+ 1 row in Set (0.00 sec) mysql> Exit Bye # [Root@linuxprobe ~]# mysqldump-u root-p---all-databases--lock-all-tabl Es--events > Mysql_dump.sql # Backup Database Enter password: [root@linuxprobe ~]# mysql-u root-p Enter password:welcome t o The MySQL Monitor. Commands End With;
or \g. Your MySQL Connection ID is 5 server version:5.6.26-log mysql Community Server (GPL) Copyright (c) Watts, 2015, Oracle an d/or its affiliates.

All rights reserved. Oracle is a registered trademark to Oracle Corporation and/or its affiliates.

The other names may is trademarks of their respective owners. Type ' help, ' or ' \h ' for help.

Type ' \c ' to clear the current input statement. mysql> unlock tables; # unlock Query OK, 0 rows Affected (0.00 sec) mysql> exit Bye [root@linuxprobe ~]# SCP Mysql_dump.sql VDEVOPS.ORG@/TMP/CP : Cannot create regular file ' vdevops.org@/tmp/': No such file or directory [Root@linuxprobe ~]# SCP Mysql_dump.sql vdevop S.org:/tmp/the authenticity of host ' vdevops.org (10.1.1' Can ' t be established.
ECDSA key fingerprint is f8:d2:55:54:8f:e8:43:e0:ee:aa:d6:8d:53:8c:8e:85. Are you sure your want to continue connecting (yes/no)?
Yes warning:permanently added ' vdevops.org ' (ECDSA) to the list of known hosts. 


 Mysql_dump.sql

Slave end:

[Root@vdevops ~]# mysql-u root-p </tmp/mysql_dump.sql Enter password: [root@vdevops ~]# mysql-u Root-p Enter PA Ssword:welcome to the MySQL Monitor. Commands End With;
or \g. Your MySQL Connection ID is 3 server version:5.6.26-log mysql Community Server (GPL) Copyright (c) Watts, 2015, Oracle an d/or its affiliates.

All rights reserved. Oracle is a registered trademark to Oracle Corporation and/or its affiliates.

The other names may is trademarks of their respective owners. Type ' help, ' or ' \h ' for help.

Type ' \c ' to clear the current input statement. mysql> Change Master to-> master_host= ' 10.1.1.53 ', # Master IP-> master_user= ' replica ', # replication ID- > master_password= ' password ', # replication passwd-> master_log_file= ' mysql-bin.000001 ', # bin-log number-> m   aster_log_pos=400;
# position Query OK, 0 rows affected, 2 warnings (0.03 sec) mysql> start slave; Query OK, 0 rows affected (0.01 sec) mysql> Show slave status\g *************1. Row *************************** slave_io_state:waiting for master to send event master_host:10.1.1.53 Mast Er_user:replica master_port:3306 connect_retry:60 master_log_file:mysql-bin.000001 Read_Master_Log_Pos : 475 relay_log_file:mysqld-relay-bin.000002 relay_log_pos:358 relay_master_log_file:mysql-bin.000001 Sla Ve_io_running:yes Slave_sql_running:yes Replicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Repl 
     icate_ignore_table:replicate_wild_do_table:replicate_wild_ignore_table:last_errno:0 Last_Error: skip_counter:0 exec_master_log_pos:475 relay_log_space:532 Until_condition:none Until_log_file:un til_log_pos:0 Master_ssl_allowed:no Master_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_S sl_cipher:master_ssl_key:seconds_behind_master:0 Master_ssl_verify_server_cert:no last_io_errno:0 Las T_io_error:last_sql_errno:0 last_sql_error:replicate_ignore_server_ids:master_server_id:101 Master_UUI  d:d47dddc3-9c70-11e6-8efb-000c29ffc05a master_info_file:/var/opt/rh/rh-mysql56/lib/mysql/master.info SQL_Delay: 0 Sql_remaining_delay:null Slave_sql_running_state:slave has read all relay log; 
  Waiting for the slave I/O thread to update it master_retry_count:86400 Master_bind:last_io_error_timestamp: 
    Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set:
 auto_position:0 1 row in Set (0.00 sec)

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.