centOS 部署服务器(三)
今天一个新的项目终于能够重新安装mysql了,分享下步骤:
1.下载地址:http://dev.mysql.com/downloads/mysql/ (选择Linux - Generic版本的Linux - Generic (glibc 2.5) (x86, 64-bit), Compressed)
2.直接将下载后的解压缩到/usr/local目录下
tar zxvf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz -C /usr/local
mv mysql-5.7.15-linux-glibc2.5-x86_64 mysql
mkdir /var/lib/mysql
3.生成并修改mysql配置文件,cp support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf:
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
character-set-server=utf8
collation-server=utf8_general_ci
[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid
# include all files from the config directory
!includedir /etc/my.cnf.d
4.由于解压后的mysql事已经编译过的了,所以不需要进行--configure ,make ,make install等步骤了,直接进入到/usr/local/mysql目录下面进行下列指令操作(可参考mysql官网:http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html):
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
mkdir data
mkdir mysql-files
chown -R mysql .
chgrp -R mysql .
bin/mysqld --initialize --user=mysql(记录好在这里生成的password,这便是mysql root用户的初始密码)
bin/mysql_ssl_rsa_setup
chown -R root .
chown -R mysql data mysql-files
bin/mysqld_safe --user=mysql &
注:在执行bin/mysqld --initalize --user=mysql的时候可能会出现如下bug:
bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
这是因为少了libaio这个依赖包,只需yum -y install libaio即可
5.建立软连接 ln -s /usr/local/mysql/bin/mysql /usr/local/bin
mysql -uroot -p (输入之前记录的密码)
成功登录到mysql界面,但是发现操作任何命令始终提示You must reset your password using ALTER USER statement before executing this statement
解决方法如下:
step 1: set password = password('your new password');
step 2: alter user 'root'@'localhost' password expire never ;
step 3: flush privileges;
退出后重新登录mysql即可,密码为你新设置的密码
6.授权用户(如果没有该用户则会默认创建用户和密码)
create database basename
grant all privileges on basename.* to "usertest"@'%' identified by '123456'
这样就创建了用户名为usertest,密码为123456的用户,并且它可以在任何ip地址上登录(设置的是%)
7.设置启动(/usr/lib/systemd/system,适用于centos7)
(1)vim nginx.service
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target [Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop [Install]
WantedBy=multi-user.target
启动,关闭,重启命令:systemctl start nginx systemctl stop nginx systemctl restart nginx
(2)vim mysql.service
[Unit]
Description=mysql
After=network.target remote-fs.target nss-lookup.target [Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecReload=/usr/local/mysql/support-files/mysql.server restart
ExecStop=/usr/local/mysql/support-files/mysql.server stop
#PrivateTmp=true [Install]
WantedBy=multi-user.target
启动,关闭,重启命令:systemctl start mysql systemctl stop mysql systemctl restart mysql
(3)vim php-fpm.service
[Unit]
Description=php
After=network.target remote-fs.target nss-lookup.target [Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
ExecReload=/usr/local/php/sbin/php-fpm restart
ExecStop=/usr/local/php/sbin/php-fpm stop [Install]
WantedBy=multi-user.target
启动,关闭,重启命令:systemctl start php-fpm, systemctl stop php-fpm, systemctl restart php-fpm
(4)vim redis.service
[Unit]
Description=Redis
After=network.target remote-fs.target nss-lookup.target [Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecStop=kill -INT `cat /tmp/redis.pid`
User=www
Group=www [Install]
WantedBy=multi-user.target
启动,关闭,重启命令:systemctl start redis, systemctl stop php-fpm, systemctl restart redis
编辑了或新增了service文件后需要systemctl daemon-reload一下service才会起作用
centOS 部署服务器(三)的更多相关文章
- 为什么使用centos部署服务器
这个是实验室同学面试的时候,面试官问的一个问题? 为什么选择centos系统,为什么centos系统用的比较多呢? 首先我们说下redhat红帽公司,它是全球最大的linux服务提供商,它的服务是最好 ...
- centOS 部署服务器(一)
接下来我所写的博客仅仅是为了记录我的学习过程,与其他无关. 由于公司换用了亚马逊服务器,用的是它的RDS数据库,所以就没有像以前的项目部署的时候使用mysql,不过要下载安装mysql-proxy,字 ...
- centOS 部署服务器(二)
(1)安装nginx 1.下载地址: http://nginx.org/en/download.html ,并解压到目录下 2.安装依赖包 yum -y install pcre* yum -y i ...
- Tigase XMPP Server在CentOS部署和配置
Tigase XMPP Server在CentOS部署与配置 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs 以下讲述Tigase XMPP Server ...
- Centos部署使用Jexus承载asp.net core2 web应用
一,首先安装本地开发项目用的的 core对应版本运行时: https://www.microsoft.com/net/download/linux-package-manager/centos/run ...
- CentOS Linux服务器安全设置
转自:http://www.osyunwei.com/archives/754.html 引言: 我们必须明白:最小的权限+最少的服务=最大的安全 所以,无论是配置任何服务器,我们都必须把不用的服务关 ...
- 【Linux】Centos部署MySQL
将CentOS部署MySQL需要本地配置环境.本地编译MySQL,耗时较长的情况,优化为编译成型MySQL并打包,推送并按配置部署. 首先需要在一台机器配置好环境,搭个YUM源,并将所需要的包取出备用 ...
- 使用saltstack批量部署服务器运行环境事例——批量部署nagios客户端
之前关于搭建web服务器集群实验的这篇文章http://www.cnblogs.com/cjyfff/p/3553579.html中,关于如何用saltstack批量部署服务器这一点当时没有记录到文章 ...
- SpringBoot入门教程(二)CentOS部署SpringBoot项目从0到1
在之前的博文<详解intellij idea搭建SpringBoot>介绍了idea搭建SpringBoot的详细过程, 并在<CentOS安装Tomcat>中介绍了Tomca ...
随机推荐
- MT6737 Android N 平台 Audio系统学习----录音到播放录音流程分析
http://blog.csdn.net/u014310046/article/details/54133688 本文将从主mic录音到播放流程来进行学习mtk audio系统架构. 在AudioF ...
- Windows Server 2012 修改桌面图标
在virtualbox 4.2.18中装了个Windows Server 2012 来体验下,结果发现桌面图标都不知道在哪改.在百度文库上找到了解决方法:http://wenku.baidu.com/ ...
- Eclipse配置python环境
主要分为四步 1.安装java环境 2.在Eclipse下安装Pydev 1)启动 Eclipse,利用 Eclipse Update Manager 安装 PyDev.在 Eclipse 菜单栏中找 ...
- codeforces B. George and Round 解题报告
题目链接:http://codeforces.com/contest/387/problem/B 题目意思:给出1-n个问题,以及要满足是good rounde条件下这n个问题分别需要达到的compl ...
- 使用 WinSCP(下载) 上文件到 Linux图文教程
问题导读: 1.如何远程链接? 2.如何上传文件? 3.如何对立面的文件进行操作? 4.什么情况下会链接失败? https://yunpan.cn/cYWtNMycjeVPv 访问密码 4f7 ...
- 开发板启动时,内核打印出"can't access tty,job control turned off"
启动后的最后一行提示can't access tty,job control turned off, 这说明没有进入到控制台,原因就在于文件系统的/etc/inittab 这个文件里有问题 vi /e ...
- 一、mysql简述
该套讲义参考动力节点郭鑫老师的mysql视频整理所得 1.DBMS--数据库管理系统 Data Base Management System eg: mysql数据库管理系统 2.DB--数据库/仓 ...
- <正则吃饺子> :关于新项目的环境搭建(一)
来到新的公司,需要使用myeclipse.maven.svn.tomcat.mysql: 对于先前一直只用 netbeans 的我,在这里把环境搭建 的情况记录下来.来加深自己的学习和帮助后来者. 第 ...
- In-App Purchase Programming Guide----(一) ---- About In-App Purchase
About In-App Purchase In-App Purchase allows you to embed a store inside your app using the Store Ki ...
- 极客时间_Vue开发实战_05.Vue组件的核心概念(1):属性
05.Vue组件的核心概念(1):属性 代码地址: https://github.com/tangjinzhou/geektime-vue-1/blob/master/%E6%BC%94%E7%A4% ...