CentOS 7.2 Yum安裝MySQL 5.6
配置CentOS SCLo源
[3] 新增 CentOS SCLo Software collections Repository.
[[email protected]~]# yum -y install centos-release-scl-rh centos-release-scl
# set [priority=10]
[[email protected]~]# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
[[email protected]~]# 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
[[email protected]~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
[[email protected] ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
yum安裝MySQL
# 安裝mysql
[[email protected]~]# yum --enablerepo=centos-sclo-rh -y install rh-mysql56-mysql-server
# 載入環境變數
[[email protected] ~]# scl enable rh-mysql56 bash
[[email protected] ~]# mysql -V
mysql Ver 14.14 Distrib 5.6.26, for Linux (x86_64) using EditLine wrapper
[[email protected] ~]# which mysql
/opt/rh/rh-mysql56/root/usr/bin/mysql
# 設定mysql開機自啟動
[email protected] ~]# vi /etc/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.
[[email protected] ~]# vi /etc/opt/rh/rh-mysql56/my.cnf.d/mysql-server.cnf
# add follows within [mysqld] section
[mysqld]
character-set-server=utf8
[[email protected] ~]# systemctl start rh-mysql56-mysqld
[[email protected] ~]# systemctl enable rh-mysql56-mysqld
[[email protected] ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS 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 will be blank,
so you should just press enter here.
Enter current password for root (enter for 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 an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
# remove anonymous users
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
# disallow root login remotely
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
# 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 will ensure that all changes made so far
will take effect immediately.
# reload privilege tables
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[[email protected] ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be 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
開啟防火牆
[[email protected] ~]# firewall-cmd –add-service=mysql –permanent
success
[[email protected] ~]# firewall-cmd –reload
success
- 同樣使用yum在vdevops.org上面安裝mysql,安裝步驟參考上面
MySQL 主從
- Master端:linuxprobe
[[email protected]~]# 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
[[email protected] ~]# 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 of Oracle Corporation and/or its
affiliates. Other names may be 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 [email protected]'%' 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
開啟防火牆
[[email protected] ~]# firewall-cmd –add-service=mysql –permanent
success
[[email protected] ~]# firewall-cmd –reload
success
- Slave端: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=102
# read only
read_only=1
# define own hostname
report-host=node01.srv.world
[root@vdevops~]# systemctl restart rh-mysql56-mysqld
- Master端:備份資料庫
[[email protected] ~]# 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) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be 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; # 鎖表
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
#
[[email protected] ~]# mysqldump -u root -p --all-databases --lock-all-tables --events > mysql_dump.sql # 備份資料庫
Enter password:
[[email protected] ~]# mysql -u root -p
Enter password:
Welcome to 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) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> unlock tables; # 解鎖
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[[email protected] ~]# scp mysql_dump.sql [email protected]/tmp/
cp: cannot create regular file ‘[email protected]/tmp/’: No such file or directory
[[email protected] ~]# scp mysql_dump.sql vdevops.org:/tmp/
The authenticity of host 'vdevops.org (10.1.1.56)' 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 you want to continue connecting (yes/no)? yes
Warning: Permanently added 'vdevops.org' (ECDSA) to the list of known hosts.
mysql_dump.sql
- Slave 端:
[[email protected] ~]# mysql -u root -p < /tmp/mysql_dump.sql
Enter password:
[[email protected] ~]# 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) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be 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
-> master_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
Master_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
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_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:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 101
Master_UUID: 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)
相關推薦
CentOS 7.2 Yum安裝MySQL 5.6
配置CentOS SCLo源 [3] 新增 CentOS SCLo Software collections Repository. [[email protected]~]# yum -y install centos-release-scl-
yum安裝mysql 5.6/7等各個版本
目錄 修改密碼 roo 輸入密碼 list -- 發現 arch leg http://repo.mysql.com/yum/1.新開的雲服務器,需要檢測系統是否自帶安裝mysql# yum list installed | grep mysql2.如果發現有系統自帶mys
CentOS 7.2下安裝Mono 5.0
nbsp 很好 all win ack style 領域 logs 平臺 微軟Build2017大會期間.NET領域的.NET core之外,就是Visual Studio For Mac,大家都知道Visual Studio For Mac 是基於Mono運行的,Mono
linux CentOS6.5 yum安裝mysql 5.6
linux centos6.5 yum安裝mysql 5.6直接按步驟安裝# wget # rpm -ivh mysql-community-release-el6-5.noarch.rpm [[email protected]/* */ ~]# yum repolist all | grep
centos6.8 yum安裝mysql 5.6
centos6.8 yum安裝mysql 5.6一、檢查系統是否安裝其他版本的MYSQL數據 yum list installed | grep mysql yum -y remove mysql-libs.x86_64 二、安裝及配置 wget http://repo.mysql.com/mysql-co
CentOS 7源碼編譯mysql-5.6.37
。/;’1.1安裝依賴yum install ncurses-devel libaio-devel -yrpm -qa ncurses-devel libaio-devel1.2安裝cmakeyum install cmake -yrpm -qa cmake1.3創建mysql用戶useradd -s /sb
在 CentOS 7 上 yum 安裝 MYSQL 8.0
MySQL1、配置 yum 源rpm -i https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm2、安裝 MySQL Serveryum install mysql-community-{server,client,commo
Linux CentOS 7.0線上安裝MySQL 5.7版本
1、配置YUM源 在MySQL官網中下載YUM源rpm安裝包:http://dev.mysql.com/downloads/repo/yum/ 下載mysql源安裝包 shell> wget http://dev.mysql.com/get/mysql57-commu
CentOS 7使用yum安裝MySQL
文章目錄 安裝指南 1.下載mysql的repo源 2.安裝`mysql-community-release-el7-5.noarch.rpm`包 3.安裝mysql 4.重置mysq
CentOS 7.2下安裝PXC 5.7.21
PXC的安裝非常簡單。 --軟體下載 https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/LATEST/ --基礎環境準備 [[email protected] ~]# vim /etc/hosts ---在3個
CentOS 7上編譯安裝MySQL 5.5
MySQL服務是一個真正的多執行緒、多使用者的SQL資料庫服務,憑藉其高效能、高可靠和易於使用的特性,成為伺服器領域中最受歡迎的開源資料庫系統。為了確保MySQL資料庫功能的完整性。可定製性,將採用原始碼編譯的方式安裝MySQL資料庫系統。 案例老版本(mysql-5.5.24.tar.gz) •MyS
CentOS 7.2下安裝Python 3.6.2
檢視python2.7 1、下載:wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz 2、解壓:tar -xvJf Python-3.6.2.tar.xz 或者 xz -d Pytho
CentOS 7下原始碼安裝MySQL 5.7
網上說linux安裝mysql服務分兩種安裝方法: ①原始碼安裝,優點是安裝包比較小,只有幾十M左右,缺點是安裝依賴的庫多,安裝編譯時間長,安裝步驟複雜容易出錯; ②使用官方編譯好的二進位制檔案安裝,優點是安裝速度快,安裝步驟簡單,缺點是安裝包很大,300M左右(5.7版
linux CentOS6 yum安裝mysql 5.6
原文連結 https://www.cnblogs.com/renjidong/p/7047396.html 1.新開的雲伺服器,需要檢測系統是否自帶安裝mysql # yum list installed | grep mysql 2.如果發現有系統自帶mysql,果斷這麼
CentOS 7.3下安裝MySQL 5.7
1、 下載 選擇你需要安裝的版本,這裡我的電腦是CentOS7.3 64位 然後下載 RPM Bundle,這個是幾個程式的合集包。 然後開始下載。。。。 2、 解壓安裝包 解壓mysql-5.7.20-1.el7.x86_64.rp
CentOS 7 用yum安裝 MySQL
首先CentOS7 已經不支援mysql,因為收費了你懂得,所以內部集成了mariadb,而安裝mysql的話會和mariadb的檔案衝突,所以需要先解除安裝掉mariadb,以下為解除安裝mariadb,安裝mysql的步驟。 1.列出所有被安裝的rpm package $ rpm -qa | grep
CentOS 6.5通過yum安裝mysql 5.5、5.6、5.7版本
yum安裝mysql mysql5.5 mysql5.6 mysql5.7 1、安裝mysql的yum源,這個源包括5.5、5.6、5.7版本:備註:如果要專門下載某個版本,可以到http://dev.mysql.com/downloads/repo/yum下載。[root@agile ~]#
centos 6.6 yum安裝mysql 5.7.16
先到 yum 安裝庫 http://repo.mysql.com/ 查詢需要的mysql yum 包 這裡用mysql57-community-release-el6-8.noarch 安裝5.
CentOS 7 安裝MySQL 5.6遇到問題及解決方案
linux localhost not ces name 解決 info target case centos下安裝mysql真的沒有想象中那麽容易,在這裏我總結一下遇到的問題 1. ERROR 2002 (HY000): Can’t connect to loca
centos 7 安裝 MySQL 5.6
計算機 mysqld rpm安裝 unity 文件中 change root server class 由於Centos7 默認數據庫是mariabd,所以通過rpm安裝MySQL需要卸載原有的Mariabd,再下載所有的依賴包比較麻煩且容易出錯。通過yum的方式安裝。