mgm6608美高梅app下载-mgm集团美高梅登录

mgm6608美高梅app下载以独家报道、社区、博客和专题策划等方式引领产业潮流,mgm集团美高梅登录为足球爱好者以及体育爱好者提供足球上网,让你无后顾之忧!,拥有多位香港乐坛红星。

同样使用yum在vdevops.org上面安装mysql,同样使用

日期:2020-02-02编辑作者:mgm集团美高梅登录

本文实例为大家分享CentOS 7.2 Yum安装mysql5.6的方法,供大家参考,具体内容如下

CentOS 7.2 Yum编译安装MySQL 5.6,centosyum

本文实例为大家分享CentOS 7.2 Yum安装mysql5.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
[roo[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

[[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 server ID (different one from Master Host)
server-id=102
# read only
read_only=1
# define own hostname
report-host=node01.srv.world
[[email protected]~]# 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 statusG
*************************** 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)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持帮客之家。

7.2 Yum编译安装MySQL 5.6,centosyum 本文实例为大家分享CentOS 7.2 Yum安装mysql5.6的方法,供大家参考,具体内容如下 配置CentOS SCLo源 [3] 添加...

CentOS 6.4下编译安装MySQL5.6.14教程,centosmysql5.6.14

概述:

CentOS 6.4下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.14。

正文:

一、卸载旧版本

使用下面的命令检查是否安装有MySQL Server

rpm -qa | grep mysql

有的话通过下面的命令来卸载掉

rpm -e mysql //普通删除模式
rpm -e --nodeps mysql 
// 强力删除模式,如果使用上面命令删除时,
提示有依赖的其它文件,则用该命令可以对其进行强力删除

二、安装MySQL

安装编译代码需要的包

yum -y install make gcc-c++ cmake bison-devel ncurses-devel

下载MySQL 5.6.14

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz
tar xvf mysql-5.6.14.tar.gz
cd mysql-5.6.14

编译安装

cmake 
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
-DMYSQL_DATADIR=/usr/local/mysql/data 
-DSYSCONFDIR=/etc 
-DWITH_MYISAM_STORAGE_ENGINE=1 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_MEMORY_STORAGE_ENGINE=1 
-DWITH_READLINE=1 
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock 
-DMYSQL_TCP_PORT=3306 
-DENABLED_LOCAL_INFILE=1 
-DWITH_PARTITION_STORAGE_ENGINE=1 
-DEXTRA_CHARSETS=all 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci

make && make install

编译的参数可以参考

整个过程需要30分钟左右……漫长的等待

三、配置MySQL

设置权限

使用下面的命令查看是否有mysql用户及用户组

cat /etc/passwd 查看用户列表
cat /etc/group 查看用户组列表

如果没有就创建

groupadd mysql
useradd -g mysql mysql

修改/usr/local/mysql权限

chown -R mysql:mysql /usr/local/mysql

修改/usr/local/mysql权限

初始化配置

进入安装路径

cd /usr/local/mysql

进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置!

注意:在CentOS 6.4版操作系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。

在使用"yum update"更新系统后,需要检查下/etc目录下是否会多出一个my.cnf,如果多出,将它重命名成别的。否则,MySQL将使用这个配置文件启动,可能造成无法正常启动等问题。

启动MySQL

添加服务,拷贝服务脚本到init.d目录,并设置开机启动

cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start --启动MySQL

配置用户

MySQL启动成功后,root默认没有密码,我们需要设置root密码。

设置之前,我们需要先设置PATH,要不不能直接调用mysql

修改/etc/profile文件,在文件末尾添加

PATH=/usr/local/mysql/bin:$PATH
export PATH

关闭文件,运行下面的命令,让配置立即生效

source /etc/profile

现在,我们可以在终端内直接输入mysql进入,mysql的环境了

执行下面的命令修改root密码

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

若要设置root用户可以远程访问,执行

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;

红色的password为远程访问时,root用户的密码,可以和本地不同。

配置防火墙

防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口

打开/etc/sysconfig/iptables

在“-A INPUT –m state --state NEW –m tcp –p –dport 22 –j ACCEPT”,下添加:

-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT

然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:

service iptables restart

OK,一切配置完毕,你可以访问你的MySQL了~

2014年12月02日添加:

CentOS 7中默认使用Firewalld做防火墙,所以修改iptables后,在重启系统后,根本不管用。

Firewalld中添加端口方法如下:

firewall-cmd --zone=public --add-port=3306/tcp --permanent

firewall-cmd --reload

精彩专题分享:mysql不同版本安装教程 mysql5.7各版本安装教程 mysql5.6各版本安装教程

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持帮客之家。

6.4下编译安装MySQL5.6.14教程,centosmysql5.6.14 概述: CentOS 6.4下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的...

配置CentOS SCLo源

[3] 添加 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-scl.repo[root@dlp ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

yum安装MySQL

# 安装mysql[root@linuxprobe~]# yum --enablerepo=centos-sclo-rh -y install rh-mysql56-mysql-server# 加载环境变量[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@linuxprobe ~]# which mysql /opt/rh/rh-mysql56/root/usr/bin/mysql# 设置mysql开机自启动root@linuxprobe ~]# vi /etc/profile.d/rh-mysql56.sh#!/bin/bashsource /opt/rh/rh-mysql56/enableexport 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]character-set-server=utf8[root@linuxprobe ~]# systemctl start rh-mysql56-mysqld[root@linuxprobe ~]# systemctl enable rh-mysql56-mysqld[root@linuxprobe ~]# mysql_secure_installationNOTE: 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 currentpassword for the root user. If you've just installed MySQL, andyou 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 MySQLroot user without the proper authorisation.# set root passwordSet root password [Y/n] yNew password:Re-enter new password:Password updated successfully!Reloading privilege tables.. ... Success!By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.# remove anonymous usersRemove anonymous users [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.# disallow root login remotelyDisallow root login remotely [Y/n] y ... Success!By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.# remove test databaseRemove 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 farwill take effect immediately.# reload privilege tablesReload privilege tables now [Y/n] y ... Success!Cleaning up...All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!

[root@linuxprobe ~]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 13Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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 exitBye

开启防火墙

[root@linuxprobe ~]# firewall-cmd –add-service=MySQL –permanent success [root@linuxprobe ~]# firewall-cmd –reload success

本文由mgm6608美高梅app下载发布于mgm集团美高梅登录,转载请注明出处:同样使用yum在vdevops.org上面安装mysql,同样使用

关键词:

目前 MySQL 支持的免费备份工具有

本文讨论 MySQL的备份和恢复机制,以及如何维护数据表,包括最主要的两种表类型: MyISAM 和Innodb ,文中设计的 MyS...

详细>>

对于在数据创建表时,BLOB 类型区分大小写

前言 MySQL的数据类型: 这篇文章主要涉及到在数据创建表时,遇到ERROR 1215 (HY000): Cannot addforeign key constraint问题方面的...

详细>>

实现代码简洁

mgm6608美高梅app下载 ,今天群里有人问了个问题是这样的: 然后有群友是这样回答的 复制代码 代码如下: select name,...

详细>>

mconfig物料配置表

这两天项目里出了一个问题,LIMIT使用后报错。需求是这样的,我有3张表,infor信息表,mconfig物料配置表,maaply物料...

详细>>