Linux_MySql_tar_安装(转)
系统版本:CentOs 7.*
Mysql版本:5.7.17(自己测试版本)
根据博主【大大的橙子】博文转载记录(大部分照搬了,只修改少许部分)
一、基本环境部署
#卸载系统自带的Mariadb
[root@hdp265dnsnfs ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@hdp265dnsnfs ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64 #删除etc目录下的my.cnf文件
[root@hdp265dnsnfs ~]# rm /etc/my.cnf
rm: cannot remove ?etc/my.cnf? No such file or directory #检查mysql是否存在
[root@hdp265dnsnfs ~]# rpm -qa | grep mysql #检查mysql组和用户是否存在,如无创建
[root@hdp265dnsnfs ~]# cat /etc/group | grep mysql
[root@hdp265dnsnfs ~]# cat /etc/passwd | grep mysql #创建mysql用户组
[root@hdp265dnsnfs ~]# groupadd mysql
#创建一个用户名为mysql的用户并加入mysql用户组
[root@hdp265dnsnfs ~]# useradd -g mysql mysql
#制定password 为111111
[root@hdp265dnsnfs ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully. #由于我的/usr/local空间不足,所以我安装到/var
[root@hdp265dnsnfs var]# tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
[root@hdp265dnsnfs var]# mv mysql-5.7.18-linux-glibc2.5-x86_64/ mysql57 #更改所属的组和用户
[root@hdp265dnsnfs var]# chown -R mysql mysql57/
[root@hdp265dnsnfs var]# chgrp -R mysql mysql57/
[root@hdp265dnsnfs var]# cd mysql57/
[root@hdp265dnsnfs mysql57]# mkdir data
[root@hdp265dnsnfs mysql57]# chown -R mysql:mysql data
二、MySql配置
[root@hdp265dnsnfs mysql57]# vi /etc/my.cnf
....
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
skip-name-resolve
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=/var/mysql57
# 设置mysql数据库的数据的存放目录
datadir=/var/mysql57/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
.....
#保存退出 :wq
三、MySql安装与初始化
[root@hdp265dnsnfs mysql57]# bin/mysql_install_db --user=mysql --basedir=/var/mysql57/ --datadir=/var/mysql57/data/
2017-04-17 17:40:02 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-04-17 17:40:05 [WARNING] The bootstrap log isn't empty:
2017-04-17 17:40:05 [WARNING] 2017-04-17T09:40:02.728710Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2017-04-17T09:40:02.729161Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-04-17T09:40:02.729167Z 0 [Warning] Changed limits: table_open_cache: 407 (requested 2000)
[root@hdp265dnsnfs mysql57]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@hdp265dnsnfs mysql57]# chown 777 /etc/my.cnf
[root@hdp265dnsnfs mysql57]# chmod +x /etc/init.d/mysqld
[root@hdp265dnsnfs mysql57]# /etc/init.d/mysqld restart
ERROR...
PS:这上面这一步困了好久
#错误如下
150718 00:03:38 mysqld_safe Logging to '/var/log/mysqld.log'.
150718 00:03:38 mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
解:mysqld_safe启动脚本默认的从/usr/local/mysql目录中读取另外一个启动脚本mysqld,因为我的安装目录为/var/mysql57 所以找不到相关文件。
[root@hdp265dnsnfs mysql57]# cd /usr/local
[root@hdp265dnsnfs mysql57]# mkdir -p /usr/local/mysql/bin
[root@hdp265dnsnfs mysql57]# ln -s /var/mysql57/bin/mysqld /usr/local/mysql/bin/mysqld
[root@hdp265dnsnfs mysql57]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
四、其他操作
#加入环境变量
[root@hdp265dnsnfs mysql57]# vi /etc/profile
...
export PATH=$PATH:/var/mysql57/bin
...
#保存退出 :wq
#获得初始密码
[root@hdp265dnsnfs mysql57]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2017-04-17 17:40:02
_pB*3VZl5T<6
#修改MySql密码
[root@hdp265dnsnfs bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.18 Copyright (c) 2000, 2017, 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> set PASSWORD = PASSWORD('111111');
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec) #添加远程访问权限
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> select host,user from user;
+-----------+-----------+
| host | user |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
+-----------+-----------+
rows in set (0.00 sec)
#create user 'xxx'@'%' identified by '123'; 这里 @‘%’ 表示在任何主机都可以登录 #重启生效(ps:CENTOS 6.* 系列使用service mysqld (start|stop|status)操作)
[root@hdp265dnsnfs /]# bin/systemctl restart mysql.service
[root@hdp265dnsnfs /]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS! #在任何目录下可以登录MySql
ln -s /var/mysql57/bin/mysql /usr/bin/mysql
五、将3360端口加入开放端口
# centos 7
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# centos 6
# 用vi编辑器打开文档添加以下:vi /etc/sysconfig/iptables
# 打开端口:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
# 关闭端口:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7777 -j DROP
# 重启防火墙
/etc/init.d/iptables restart
CentOS 6:
1、开启端口(以80端口为例)
方法一:
/sbin/iptables -I INPUT -p tcp --dport 端口号 -j ACCEPT 写入修改
/etc/init.d/iptables save 保存修改
service iptables restart 重启防火墙,修改生效
方法二:
vi /etc/sysconfig/iptables 打开配置文件加入如下语句:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 端口号 -j ACCEPT 重启防火墙,修改完成
2、关闭端口
方法一:
/sbin/iptables -I INPUT -p tcp --dport 端口号 -j DROP 写入修改
/etc/init.d/iptables save 保存修改
service iptables restart 重启防火墙,修改生效
方法二:
vi /etc/sysconfig/iptables 打开配置文件加入如下语句:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 端口号 -j DROP 重启防火墙,修改完成
3、查看端口状态
/etc/init.d/iptables status
六、添加开机自启
chkconfig --add mysqld
PS:必要时关闭防火墙
# 查看有哪些端口被防火墙允许
firewall-cmd 命令 https://blog.csdn.net/s_p_j/article/details/80979450
firewall-cmd --list-ports
# centos 7
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
# centos 6
# 临时关闭防火墙
service iptables stop
# 永久关闭防火墙
chkconfig iptables off
Linux_MySql_tar_安装(转)的更多相关文章
- docker——容器安装tomcat
写在前面: 继续docker的学习,学习了docker的基本常用命令之后,我在docker上安装jdk,tomcat两个基本的java web工具,这里对操作流程记录一下. 软件准备: 1.jdk-7 ...
- 网络原因导致 npm 软件包 node-sass / gulp-sass 安装失败的处理办法
如果你正在构建一个基于 gulp 的前端自动化开发环境,那么极有可能会用到 gulp-sass ,由于网络原因你可能会安装失败,因为安装过程中部分细节会到亚马逊云服务器上获取文件.本文主要讨论在不变更 ...
- Sublime Text3安装JsHint
介绍 Sublime Text3使用jshint依赖Nodejs,SublimeLinter和Sublimelinter-jshint. NodeJs的安装省略. 安装SublimeLinter Su ...
- Fabio 安装和简单使用
Fabio(Go 语言):https://github.com/eBay/fabio Fabio 是一个快速.现代.zero-conf 负载均衡 HTTP(S) 路由器,用于部署 Consul 管理的 ...
- gentoo 安装
加载完光驱后 1进行ping命令查看网络是否通畅 2设置硬盘的标识为GPT(主要用于64位且启动模式为UEFI,还有一个是MBR,主要用于32位且启动模式为bois) parted -a optima ...
- Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级
Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级 环境:OEL 5.7 + Oracle 10.2.0.5 RAC 5.安装Database软件 5. ...
- Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part1:准备工作
Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part1:准备工作 环境:OEL 5.7 + Oracle 10.2.0.5 RAC 1.实施前准备工作 1.1 服务器安装操 ...
- 【原】nodejs全局安装和本地安装的区别
来微信支付有2年多了,从2年前的互联网模式转变为O2O模式,主要的场景是跟线下的商户去打交道,不像以往的互联网模式,有产品经理提需求,我们帮忙去解决问题. 转型后是这样的,团队成员更多需要去寻找业务的 ...
- tLinux 2.2下安装Mono 4.8
Tlinux2.2发行版基于CentOS 7.2.1511研发而成,内核版本与Tlinux2.0发行版保持完全一致,更加稳定,并保持对Tlinux2.0的完全兼容.Mono 4版本要求CentOS 7 ...
随机推荐
- js获取当前日期,并计算几天后日期
获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS” function getNowFormatDate() { var date = new Date(); var seperator ...
- SVN 错误收集
一.the working copy is locked due to a previous error 解决办法:在 Cornerstone 右键本地工程 --> clean.
- 配置openfire环境
Openfire 的安装和配置 1. 下载最新的openfire安装文件 官方下载站点:http://www.igniterealtime.org/downloads/index.jsp#openfi ...
- 微服务RPC框架选美
原文:http://p.primeton.com/articles/59030eeda6f2a40690f03629 1.RPC 框架谁最美? Hello,everybody!说到RPC框架,可能大家 ...
- 3、class文件加载过程
1.加载2.链接(检验/准备/解析) 1/检验过程:检验class的数据格式.2/准备过程:创建静态域,并将这些域设为默认值.3/解析过程:在一个Java类中会包含对其它.类或接口的形式引用,包括它的 ...
- Oracle出现与并行相关的ORA-00600时的调查方法
出现了 ORA-00600[kxfpqsod_qc_sod], 如何调查呢? 例如:从trace 文件的 Call Stack,可以看到 Error: ORA-600 [kxfpqsod_qc_sod ...
- 使用pandas,7行代码实现朴素贝叶斯
作者:hhh5460 大抵分成两类 一.离散的.标签化的数据 原文没有使用pandas,我使用pandas重新实现了朴素贝叶斯算法,看起来非常简洁.清爽. import pandas as pd '' ...
- Scracpy爬取图片实例
非常简单,直接上爬虫代码 # -*- coding: utf-8 -*- import scrapy import urllib import logging class TopitComSpider ...
- [转载]windows下PHP + Nginx curl访问本地地址超时卡死问题的解决方案
原因: windows 下 nginx+php环境,不支持并发. 解决方案: 1.在配置nginx vhost时,需要同时运行的网站设置不同的fastcgi_pass的端口号 server { ser ...
- unity中利用纯物理工具制作角色移动跳跃功能
using System.Collections;using System.Collections.Generic;using UnityEngine; public class Player : M ...