关闭

[centos] 环境安装之 mysql离线版压缩包(mysql-5.7.16-linux-glibc2.5-x86_64.tar)

标签: centosmysql
137人阅读 评论(0) 收藏 举报
分类:

大致步骤如下

1.下载
2.检查系统有无mysql
3.创建 mysql用户
4.解压jar包
5.更改所有文件权限为mysql:mysql
6.复制配置文件到/etc/my.cnf并编辑
7.复制mysqld服务到/etc/init.d/mysqld
8.运行 ./bin/mysqld –initialize
9.启动服务(出现.pid文件错误用chown -R mysql:mysql /usr/local/mysql/data即可)
10.用mysqld –initialize 产生的密码登录mysql
11修改密码

具体为:


下载:http://dev.mysql.com/downloads/mysql/#downloads


rpm -qa |grep mysql

有则删除:yum remove pkg


创建用户

groupadd mysql 
useradd -r -g mysql mysql

解压

tar xvf mysql-5.7.16-linux-glibc2.5-x86_64.tar

移动

mv mysql-5.7.16-linux-glibc2.5-x86_64 /usr/local/mysql/

然后进入目录

cd /usr/local/mysql

复制配置文件

cp support-files/my-default.cnf /etc/my.cnf

有覆盖提示输入:yes

编辑my.cnf文件

vi /etc/my.cnf

我的是:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# * DO NOT EDIT THIS FILE. It’s a template which will be copied to the
# * default location during install, and will be replaced if you
# * upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir =/usr/local/mysql
datadir =/usr/local/mysql/data
# port = …..
# server_id = …..
# socket = …..

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

然后把mysqld服务安装

cp support-files/mysql.server /etc/init.d/mysqld

然后初始化数据库

./bin/mysqld --initialize

这一步会产生一个随机密码(也可能会出错,很多种错误,我不列举,本来就是给自己看,如果你有问题欢迎截图来回复,我是失败了n次才成功,很多错误都见过)


如果初始化成功了,那么就开启服务吧

service mysqld start

这里可能会出现的错误有:

The server quit without updating PID file (/usr/local/mysql/data/snsgou.pid).

这个是因为权限不够吧!因为至始至终,mysql文件夹下的data文件夹都不是我们创建的,也就是自动创建的!
所以需要重新给下权限:

chown mysql:mysql /usr/local/mysql/data

接着在重启电脑(为了关闭mysqld进程..我不会kill -9 杀进程,老是杀错,还是重启实在),然后在重新 service mysqld start 试试!


欢迎回复讨论mysql的安装!据说centos7用yum安装是MariaDB!有空讨论!还有yum换成网易的源可以见菜鸟教程:http://www.runoob.com/linux/linux-yum.html

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:19590次
    • 积分:690
    • 等级:
    • 排名:千里之外
    • 原创:49篇
    • 转载:2篇
    • 译文:0篇
    • 评论:12条
    最新评论