centos 7安装mysql5.7版本
2016-09-03 12:35
369 查看
环境:centos 7,mysql版本:5.7.14
解压mysql5.7压缩包
将解压的文件夹重命名为mysql5.7
命令省略
创建用户
groupadd mysql
useradd -r -g mysql mysql
授权文件夹
chmod 750 mysql5.7
chown -R mysql mysql5.7
chgrp -R mysql mysql5.7
在mysql5.7中创建存放数据的文件夹
mkdir data
chmod 755 data
chown 750 data
chown -R mysql data
chgrp -R mysql data
在mysql5.7中创建存放pid和log目录并授权(省略命令)
配置mysql配置文件
在/etc/my.cnf配置文件上配置
[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 = .....
# datadir = .....
# 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
basedir=/opt/mysql5.7
datadir=/opt/mysql5.7/data
port=3306
socket=/opt/mysql5.7/mysql.sock
pid-file=/opt/mysql5.7/pid/mysql.pid
log-error=/opt/mysql5.7/log/error.log
character_set_server=utf8
explicit_defaults_for_timestamp=true
进入bin目录初始化
./bin/mysqld --user=mysql --basedir=/opt/mysql5.7 --datadir=/opt/mysql5.7/data --initialize
初始化后进入指定的日志目录查看生成的日志
里面有初始化密码
修改在support-files下服务脚本mysql.service
配置basedir和datadir
basedir=/opt/mysql5.7
datadir=/opt/mysql5.7/data
启动运行
./mysql.server start --user=mysql
查看服务是否启动
ps -ef | grep mysql
通过bin目录下的mysql客户端连接mysql
./bin/mysql -uroot -p
出现
原因:由于将生成的mysql.sock文件放到mysql5.7目录中,因此找不到
通过创建软链接来处理
ln -s /opt/mysql5.7/mysql.sock /tmp/mysql.sock
在次连接,使用在初始化时,在error.log文件中生成的临时密码进入
-----------------------------------------------------------------------------------------------------------------------------------------------------------
测试使用
show databases;
出现
更新密码
alter user 'root'@'localhost' identified by 'root';
将root用户设置成可以远程登录连接
grant all privileges on *.* to root@'%' identified by 'root';
解压mysql5.7压缩包
将解压的文件夹重命名为mysql5.7
命令省略
创建用户
groupadd mysql
useradd -r -g mysql mysql
授权文件夹
chmod 750 mysql5.7
chown -R mysql mysql5.7
chgrp -R mysql mysql5.7
在mysql5.7中创建存放数据的文件夹
mkdir data
chmod 755 data
chown 750 data
chown -R mysql data
chgrp -R mysql data
在mysql5.7中创建存放pid和log目录并授权(省略命令)
配置mysql配置文件
在/etc/my.cnf配置文件上配置
[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 = .....
# datadir = .....
# 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
basedir=/opt/mysql5.7
datadir=/opt/mysql5.7/data
port=3306
socket=/opt/mysql5.7/mysql.sock
pid-file=/opt/mysql5.7/pid/mysql.pid
log-error=/opt/mysql5.7/log/error.log
character_set_server=utf8
explicit_defaults_for_timestamp=true
[client] default-character-set=utf8
进入bin目录初始化
./bin/mysqld --user=mysql --basedir=/opt/mysql5.7 --datadir=/opt/mysql5.7/data --initialize
初始化后进入指定的日志目录查看生成的日志
里面有初始化密码
修改在support-files下服务脚本mysql.service
配置basedir和datadir
basedir=/opt/mysql5.7
datadir=/opt/mysql5.7/data
启动运行
./mysql.server start --user=mysql
查看服务是否启动
ps -ef | grep mysql
通过bin目录下的mysql客户端连接mysql
./bin/mysql -uroot -p
出现
原因:由于将生成的mysql.sock文件放到mysql5.7目录中,因此找不到
通过创建软链接来处理
ln -s /opt/mysql5.7/mysql.sock /tmp/mysql.sock
在次连接,使用在初始化时,在error.log文件中生成的临时密码进入
-----------------------------------------------------------------------------------------------------------------------------------------------------------
测试使用
show databases;
出现
更新密码
alter user 'root'@'localhost' identified by 'root';
将root用户设置成可以远程登录连接
grant all privileges on *.* to root@'%' identified by 'root';
flush privileges;使用客户端使用root/root登录
相关文章推荐
- CentOs 7 安装mysql5.7(二进制版本)
- Centos7.4 版本环境下安装Mysql5.7操作记录
- centos6.5下yum安装最新版本mysql5.7
- CentOS6.5安装MySQL5.7(也适合其他版本安装)
- Centos7环境下安装Mysql5.7版本
- Centos7.4 版本环境下安装Mysql5.7操作记录
- CentOS 5.5 升级php到5.2,mysql到5.1 (yum安装之后的为5.1.6版本过低而升级)
- centos 64位系统下yum只安装x86_64版本软件
- LNMP 最新版本+YUM方式安装指南(CentOS5.5 + Nginx 1.0.x + MySQL 5.5.x + PHP 5.3.x)
- CentOS,yum,指定php,mysql,版本安装
- CentOS快速安装最新版本的SaltStack
- Centos6.3安装OpenStack的Folsom版本(2)
- [置顶] CentOS 安装 hadoop hbase 使用 cloudera 版本。(一)
- 给centos 5.6安装最新版本的内核(kernel-2.6.38.2)
- centos使用yum快速安装osa v1.0.3版本
- CentOS下编译安装MySQL5.5.x的版本需使用Cmake编译器
- centos6.2安装http-2.4版本出错及解决方法
- LNMP 最新版本+YUM方式安装指南(CentOS5.5 + Nginx 1.0.x + MySQL 5.5.x + PHP 5.3.x)
- centos 下mysql5.1.45 二进制版本安装及多apache php版本安装
- CentOS 64位机器上安装 tomcat、jdk、mysql所需软件版本