mysql5.7如何安装部署、初始化和创建实例方法介绍

本文主要给大家介绍MySQL5.7如何安装部署、初始化和创建实例方法,文章内容都是笔者用心摘选和编辑的,具有一定的针对性,对大家的参考意义还是比较大的,下面跟笔者一起了解下mysql5.7如何安装部署、初始化和创建实例方法吧。 

专业领域包括成都做网站、成都网站建设、成都做商城网站、微信营销、系统平台开发, 与其他网站设计及系统开发公司不同,创新互联公司的整合解决方案结合了帮做网络品牌建设经验和互联网整合营销的理念,并将策略和执行紧密结合,为客户提供全网互联网整合方案。

很简单的流程

环境信息:
centos 7.2
mysql 5.7.21

mysql5.7如何安装部署、初始化和创建实例方法介绍

1.下载解压缩mysql包

cd /usr/local/
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
tar xzvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql

2.初始化mysql基础环境信息

vim /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
export MYSQL_HOME="/usr/local/mysql"
export ms="/usr/local/mysql"

3.初始化配置实例配置文件

mkdir -p /usr/local/mysql/data/mcdb
vi /usr/local/mysql/data/my.cnf
[client]
port = 3310
socket = /usr/local/mysql/data/mcdb/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
port = 3310
socket = /usr/local/mysql/data/mcdb/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/mcdb/mysql.pid
relay-log = /usr/local/mysql/data/mcdb/relay-bin
relay-log-info-file = /usr/local/mysql/data/mcdb/relay-log.info
server-id = 12
[mysqld_safe]
log-error = /usr/local/mysql/data/mcdb/mysql.err
pid-file = /usr/local/mysql/data/mcdb/mysql.pid

4.新建用户

groupadd mysql
useradd mysql -g mysql
chown mysql:mysql /usr/local/mysql -R

5.初始化mysql实例
mysqld --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mcdb --user=mysql
从返回信息最后一行获得密码,举个栗子:
yUlta1lw*uwF

6.移动配置文件到实例目录,启动该实例mysql

mv /usr/local/mysql/data/my.cnf /usr/local/mysql/data/mcdb/my.cnf
mysqld_safe --defaults-file=/usr/local/mysql/data/mcdb/my.cnf --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mcdb &

7.登录mysql
mysql -uroot -pyUlta1lw*uwF -S /usr/local/mysql/data/mcdb/mysql.sock

8.设定密码

mysql> SET PASSWORD = PASSWORD('hello2018'); 
mysql> flush privileges;

9.创建用户并开放远程登录权限
grant all privileges on *.* to 'bodie'@'%' identified by 'happybirthday' with grant option;

看完以上关于mysql5.7如何安装部署、初始化和创建实例方法,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。


文章标题:mysql5.7如何安装部署、初始化和创建实例方法介绍
文章来源:http://pwwzsj.com/article/jspdge.html