码迷,mamicode.com
首页 > 数据库 > 详细

centos7安装mysql

时间:2020-02-24 22:21:38      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:ice   需要   关闭防火墙   允许   soc   解压   登陆   编译   pts   

1. 环境准备

CentOS-7 安装好,最好是Minimal版本的

新建soft目录,上传mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz

配置好网络

2. 依赖安装

Mysql 编译安装需要使用perl,先把这些编译工具安装好

yum -y install perl

yum -y install perl-devel

yum -y install ‘perl(Data::Dumper)‘

 

3. 安装mysql

3.1. 解压

tar -zxvf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz

重命名

mv mysql-5.6.10-linux-glibc2.5-x86_64 mysql

 

mysql里面的所有放置到 /usr/local/mysql

 mkdir /usr/local/mysql

 mv * /usr/local/mysql

 

3.2. 初始化安装

3.2.1. 创建好数据目录

mkdir -p /data/mysql

 

3.2.2. 初始化

cd /usr/local/mysql/scripts

./mysql_install_db --user=root --basedir=/usr/local/mysql --datadir=/data/mysql --pid-file=/data/mysql/mysql.pid --tmpdir=/tmp  --explicit_defaults_for_timestamp=true

3.2.3. 配置my.cnf文件

 

cd /usr/local/mysql/support-files

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

cp mysql.server /etc/init.d/mysql

 

vi /etc/my.cnf

basedir = /usr/local/mysql

datadir = /data/mysql

socket = /tmp/mysql.sock

log-error = /data/mysql/error.log

pid-file = /data/mysql/mysql.pid

user = root

tmpdir = /tmp

 

3.2.4. 修改环境变量

vi /etc/profile

export MYSQL_HOME=/usr/local/mysql

export PATH=$MYSQL_HOME/bin:$PATH

source /etc/profile

 

3.2.5. 启动mysql

service mysql start

3.2.6. 登陆mysql,修改给root密码

mysql

mysql>use mysql;

mysql>update user set password=password(‘root‘) where user=‘root‘ and host=‘localhost‘;

mysql>flush privileges;

 

3.2.7. 允许远程访问

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH GRANT OPTION;

flush privileges;

 

3.2.8. 关闭防火墙

systemctl stop firewalld.service

systemctl disable firewalld.service

 

centos7安装mysql

标签:ice   需要   关闭防火墙   允许   soc   解压   登陆   编译   pts   

原文地址:https://www.cnblogs.com/zhoufly-blog/p/12359148.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!