在openstack中安装mysql5.7
在控制节点上执行
1.下载mysql二进制安装包和依赖包
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libaio-devel-0.3.109-13.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libaio-0.3.109-13.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
2.安装依赖包并解压mysql二进制安装包
#yum -y install numactl ##error while loading shared libraries: libnuma.so.1
#yum -y install openssl ##[ERROR] Could not find OpenSSL on the system
rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm
rpm -ivh libaio-devel-0.3.109-13.el7.x86_64.rpm
tar -xzvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
mv ./mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysqlrun
3.创建mysql运行用户和用户组
groupadd mysql
useradd -M -g mysql -s /sbin/nologin mysql
4.创建数据目录和日志目录并授予权限
mkdir -p /usr/local/mysqldata/data
mkdir -p /usr/local/mysqldata/binlogs
mkdir -p /usr/local/mysqldata/relaylogs
touch /usr/local/mysqldata/mysql-error.log
chown -R mysql:mysql /usr/local/mysqldata
chmod -R 770 /usr/local/mysqldata
chown -R mysql:mysql /usr/local/mysqlrun
chmod -R 770 /usr/local/mysqlrun
5.创建并配置my.cnf
mv /etc/my.cnf /etc/my.cnf_bak`date "+%Y%m%d%H%M"`
cat << EOF > /etc/my.cnf
[mysqld]
user=mysql
port=3306
#server-id=1
#binlog_format = ROW
#max_binlog_size = 1G
#expire_logs_days = 7
#log-bin=/usr/local/mysqldata/binlogs/mysql-bin
#relay-log=/usr/local/mysqldata/relaylogs/slave-relay-bin
skip-grant-tables
log-error=/usr/local/mysqldata/mysql-error.log
datadir=/usr/local/mysqldata/data
basedir=/usr/local/mysqlrun
socket=/usr/local/mysqlrun/mysql.sock
pid-file=/usr/local/mysqlrun/mysql.pid
skip-name-resolve
symbolic-links = 0
lower_case_table_names = 1
character-set-server = utf8
default-storage-engine = InnoDB
innodb_file_per_table = 1
max_connections = 2000
max_allowed_packet = 1G
interactive_timeout = 120
wait_timeout = 864000
[mysql]
socket=/usr/local/mysqlrun/mysql.sock
EOF
6.初始化mysql数据库
/usr/local/mysqlrun/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysqlrun --datadir=/usr/local/mysqldata/data
/usr/local/mysqlrun/bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysqldata/data
7.设定启动脚本中basedir和datadir的路径
sed -i '/^basedir/c\basedir=\/usr\/local\/mysqlrun' /usr/local/mysqlrun/support-files/mysql.server
sed -i '/^datadir/c\datadir=\/usr\/local\/mysqldata\/data' /usr/local/mysqlrun/support-files/mysql.server
8.将mysql工具添加到环境变量中
echo 'export PATH=/usr/local/mysqlrun/bin:$PATH' >> /etc/profile
source /etc/profile
9.设置mysql服务开机自启并启动
ln -s /usr/local/mysqlrun/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chkconfig --list
systemctl enable mysqld
systemctl restart mysqld && systemctl status mysqld
#/usr/local/mysqlrun/bin/mysqld_safe --defaults-file=/etc/my.cnf &
#ps -ef | grep mysql | grep -v grep | awk '{print $2}' |xargs kill -9
10.重置mysql数据库root密码(无需重启)
ROOT_PASSWD='m4r!adbOP'
ROOT_PASSWD_T='m4r\!adbOP'
mysql -uroot -e "update mysql.user set authentication_string=password('${ROOT_PASSWD_T}') where user='root';"
mysql -uroot -e "flush privileges;"
sed -i 's/^skip-grant-tables/#&/' /etc/my.cnf
mysql --connect-expired-password -uroot -p"${ROOT_PASSWD}" -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${ROOT_PASSWD_T}';"
mysql --connect-expired-password -uroot -p"${ROOT_PASSWD}" -e "flush privileges;"
mysql -uroot -p"${ROOT_PASSWD}" -e "show databases;"
11.设置mysql远程访问
mysql -uroot -p"${ROOT_PASSWD}" -e "update mysql.user set host='%' where user='root' and host='localhost';"
mysql -uroot -p"${ROOT_PASSWD}" -e "select user,host from mysql.user;"
12.放开防火墙(防火墙关闭也无需操作)
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --reload
在openstack中安装mysql5.7的更多相关文章
- 在centos6.5中安装mysql5.7
简介 博主最近在研究mysql的读写分离和主从复制,一台master和两台slave,三台机器在同一个局域网中,首先就就要在centos6.5中安装mysql5.7.好了,废话不多说,接下来进入正题. ...
- centos7中安装mysql5.6版本 + 主从复制
centos安装5.6版本:CentOS7下使用YUM安装MySQL5.6 主从复制:Mysql主从复制与读写分离原理及配置教程 主从复制问题及配置 卸载和安装5.7版本:CentOS 7 安装与卸载 ...
- win7下docker环境centos容器中安装mysql5.7
docker环境基于镜像skiychan/nginx-php7,进行安装 ps:skiychan/nginx-php7此镜像已封装nginx1.15.3+php7.2.9 1.环境配置 配置共享文件夹 ...
- centos7 中安装 mysql5.6 的过程
前提是Centos的环境是好的,并且相关的软件包已经安装好. 1.创建用户,并修改创建的数据目录的属主 [root@bogon ~]# useradd -M mysql -s /sbin/nologi ...
- CentOS7中安装MySQL5.7 (转)
安装必要的组件 yum install –y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio li ...
- CentOS7中安装MySQL5.7
安装必要的组件 yum install –y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio li ...
- 在centos7中安装MySQL5.7
1.下载mysql源安装包 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 2.安装mysql源 yu ...
- docker微服务部署之:四、安装docker、docker中安装mysql和jdk1.8、手动构建镜像、部署项目
docker微服务部署之:三,搭建Zuul微服务项目 1.Centos7安装Docker 详见:Centos7安装Docker 2.Docker中安装jdk1.8 详见:使用Docker构建jdk1. ...
- Linux中安装软件和各种常用命令
1.Centos7中安装mysql5.7的链接:http://blog.csdn.net/fanpeizhong/article/details/73557202 2.修改mysql默认密码的链接:h ...
随机推荐
- BZOJ 4147: [AMPPZ2014]Euclidean Nim (分类讨论博弈神题)
orz PoPoQQQ神犇,每一篇题解都写得很清楚 (看了PoPoQQQ的哲♂学三部曲,瑟瑟发抖) CODE #include <cstdio> #include <algorith ...
- Vue公共结果页面实现
需求 我希望写一个公共结果页面,满足所有模块的结果展示,页面设计要素如下: 结果图标type(成功图标,失败图标) 标题title(如:提交成功) 描述descripton(如:您的工单已提交,请等待 ...
- Zookeeper:Zookeeper集群概要
1.下载解压zookeeper 使用官网的(http://zookeeper.apache.org/releases.html#download)推荐下载镜像https://mirrors.tuna. ...
- docker并不能把部署的工作「减少为0」,比较好的情况下是「基本减少为1」
很多人说docker改变了运维世界,这句话是从群体角度来说的,是统计学意义上的改变,像mysql,python这样被大规模使用的基础应用,docker化之后为整个群体所节省的时间是非常巨大的. 有人可 ...
- 初入SG-UAP
初入SG-UAP SpriderMan 关注 2019.06.19 14:10 字数 1130 阅读 10评论 0喜欢 0 初次接触SG-UAP,将自己的见解以文字形式记录下来,希望能对初入的伙伴们有 ...
- Codeforces Round #346 (Div. 2) E题 并查集找环
E. New Reform Berland has n cities connected by m bidirectional roads. No road connects a city to it ...
- 图论小专题B
2 树 2.1 树的定义 一个只有\(N-1\)条边,且任意两个点连通的图叫做树.通过这样定义的树往往是一棵无根树,而我们通常会任意选定一个根节点使其变成有根树.有根树可以定义"父亲和儿子& ...
- Digit Division(排列组合+思维)(Gym 101480D )
题目链接:Central Europe Regional Contest 2015 Zagreb, November 13-15, 2015 D.Digit Division(排列组合+思维) 题解: ...
- php原生导出简单word表格(TP为例) (原)
后台: # 菲律宾名单word导出 public function export_word(){ $tids = $_GET['tids']; $userinfo=M("philippi ...
- flask 部署
学习 Flask,写完一个 Flask 应用需要部署的时候,就想着折腾自己的服务器.根据搜索的教程照做,对于原理一知半解,磕磕碰碰,只要运行起来了,谢天谢地然后不再折腾了,到下一次还需要部署时,这样的 ...