溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

mysql5.7如何安裝部署、初始化和創(chuàng)建實(shí)例方法介紹

發(fā)布時(shí)間:2020-05-15 10:22:36 來源:億速云 閱讀:320 作者:三月 欄目:MySQL數(shù)據(jù)庫

本文主要給大家介紹mysql5.7如何安裝部署、初始化和創(chuàng)建實(shí)例方法,文章內(nèi)容都是筆者用心摘選和編輯的,具有一定的針對性,對大家的參考意義還是比較大的,下面跟筆者一起了解下mysql5.7如何安裝部署、初始化和創(chuàng)建實(shí)例方法吧。 

很簡單的流程

環(huán)境信息:
centos 7.2
mysql 5.7.21

mysql5.7如何安裝部署、初始化和創(chuàng)建實(shí)例方法介紹

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基礎(chǔ)環(huán)境信息

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.初始化配置實(shí)例配置文件

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實(shí)例
mysqld --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mcdb --user=mysql
從返回信息最后一行獲得密碼,舉個(gè)栗子:
yUlta1lw*uwF

6.移動配置文件到實(shí)例目錄,啟動該實(shí)例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.設(shè)定密碼

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

9.創(chuàng)建用戶并開放遠(yuǎn)程登錄權(quán)限
grant all privileges on *.* to 'bodie'@'%' identified by 'happybirthday' with grant option;

看完以上關(guān)于mysql5.7如何安裝部署、初始化和創(chuàng)建實(shí)例方法,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI