赞
踩
安装依赖库
libaio-0.3.109-13.el7.x86_64.rpm
libao-1.1.0-8.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libaio-devel-0.3.109-13.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libao-1.1.0-8.el7.x86_64.rpm
rpm -ivh libaio-devel-0.3.109-13.el7.x86_64.rpm
rpm -ivh libao-1.1.0-8.el7.x86_64.rpm
下载mysql,并解压: 官网:https://dev.mysql.com/downloads/mysql/
# 解压
tar mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
# 移动并改名
mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql
添加用户和组,进入/usr/local
目录下
groupadd mysql
useradd -r -g mysql mysql
创建mysql
的data
目录
mkdir /usr/local/mysql/data/
新建my.cnf
文件 路径为/etc/my.cnf
vim /etc/my.cnf
my.cnf文件内容如下:
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
init-connect='SET NAMES utf8'
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
max_connections=50
character-set-server=utf8
default-storage-engine=INNODB
配置mysql
环境变量
# 修改权限
chmod +x /usr/local/mysql/bin/*
# 编辑配置文件
vim /etc/profile
# 配置环境变量
export PATH=$PATH:/usr/local/mysql/bin
export PATH=$PATH:/usr/local/mysql/support-files
# 使配置文件生效
source /etc/profile
初始化mysql
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
修改文件夹权限
chown -R root:root /usr/local/mysql/
chown -R mysql:mysql /usr/local/mysql/data/
启动mysql
mysql.server start
修改密码
mysql -uroot
use mysql;
update user set authentication_string=password('密码') where user='root';
flush privileges;
exit;
设置外网访问
update user set host='%' where user ='root';
flush privileges;
centos7
打开远程连接防火墙
firewall-cmd --permanent --add-port=3306/tcp
service firewalld restart
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。