mysql8.0 部署初始化和创建实例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql8.0 部署初始化和创建实例相关的知识,希望对你有一定的参考价值。
mysql8.0部署、初始化和创建实例
环境信息:
centos 7.4.1708
mysql 8.0.11
1.下载解压缩mysql包
cd /usr/local/
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
tar xzvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
mv mysql-8.0.11-linux-glibc2.12-x86_64 mysql
2.初始化mysql基础环境信息
vim /etc/profile
PATH=/opt/mysql/bin:/opt/mysql/lib:$PATH
export PATH
export MYSQL_HOME="/opt/mysql"
export ms="/opt/mysql"
3.初始化配置实例配置文件
mkdir -p /opt/mysql/data/mcdb
vi /opt/mysql/data/my.cnf
[client]
port = 3311
socket = /opt/mysql/data/mcdb/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
port = 3311
socket = /opt/mysql/data/mcdb/mysql.sock
basedir = /opt/mysql
datadir = /opt/mysql/data
pid-file = /opt/mysql/data/mcdb/mysql.pid
relay-log = /opt/mysql/data/mcdb/relay-bin
relay-log-info-file = /opt/mysql/data/mcdb/relay-log.info
server-id = 13
[mysqld_safe]
log-error = /opt/mysql/data/mcdb/mysql.err
pid-file = /opt/mysql/data/mcdb/mysql.pid
4.新建用户
groupadd mysql
useradd mysql -g mysql
chown mysql:mysql /opt/mysql -R
5.初始化mysql实例/opt/mysql/bin/mysqld --initialize --basedir=/opt/mysql --datadir=/opt/mysql/data/mcdb --user=mysql
从返回信息最后一行获得密码,举个栗子:
xHGkgc+9ea6/
6.启动该实例mysql
mv /opt/mysql/data/my.cnf /opt/mysql/data/mcdb/my.cnf
/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/data/mcdb/my.cnf --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data/mcdb 2>&1 > /dev/null &
7.登录mysql/opt/mysql/bin/mysql -uroot -pxHGkgc+9ea6/ -S /opt/mysql/data/mcdb/mysql.sock
8.设定新密码set password = ‘hello2018‘;
以上是关于mysql8.0 部署初始化和创建实例的主要内容,如果未能解决你的问题,请参考以下文章
MySQL8.0.26安装配置教程(windows 64位)