CentOS7安裝MySQL5 6詳細步驟

2021-07-06 07:07:57 字數 1721 閱讀 1700

一、安裝依賴包

yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio libaio-devel perl-data-dumper net-tools

二、建立使用者

useradd mysql

passwd mysql

三、建立相關目錄

mkdir -p /mofeng/

chmod 777 /mofeng/tmp

mkdir -p /mofeng/data/mysql/3306/

mkdir -p /mofeng/log/mysql

chown -r mysql:mysql /mofeng/data/mysql

四、解壓原始碼包

tar zxvf mysql56.tar.gz -c /mofeng/local/

五、拷貝配置檔案

mv my.cnf /mofeng/data/mysql/3306/etc/

六、初始化資料庫

/mofeng/local/mysql56/scripts/mysql_install_db –defaults-file=/mofeng/data/mysql/3306/etc/my.cnf –basedir=/mofeng/local/mysql56 –datadir=/mofeng/data/mysql/3306/data –plugin-dir=/mofeng/local/mysql56/lib/plugin –user=mysql –log-error=/mofeng/log/mysql/mysql-error.log –open-files-limit=65535 –pid-file=/mofeng/data/mysql/3306/pid/mysql.pid –socket=/mofeng/data/mysql/3306/socket/mysql.sock –port=3306

七、啟動資料庫

cd /mofeng/local/mysql56

./bin/mysqld_safe –defaults-file=/mofeng/data/mysql/3306/etc/my.cnf &

八、修改資料庫root使用者密碼

/mofeng/local/mysql56/bin/mysqladmin -u root password password -s /mofeng/data/mysql/3306/socket/mysql.sock

九、登陸資料庫

/mofeng/local/mysql56/bin/mysql -u root -p -s /mofeng/data/mysql/3306/socket/mysql.sock

十、關閉防火牆,修改selinux

1. disable firewalld service.

systemctl mask firewalld

2. stop firewalld service.

systemctl stop firewalld

十一、允許客戶端登陸資料庫

grant all on . to root@」%」 identified by 『new_password』;

flush privileges;

十二、關閉資料庫

/mofeng/local/mysql56/bin/mysqladmin shutdown -s /mofeng/data/mysql/3306/socket/mysql.sock -u root -p

Centos7離線安裝mysql5

2.將部署包存放到 opt 資料夾下 3.解壓並安裝 cd opt mkdir mysql tar xvf opt mysql 5.7.30 1.el7.x86 64.rpm bundle.tar c opt mysql cd opt mysql rpm uvh rpm nodeps force1....

Centos7使用yum安裝Mysql5 7

centos7的yum源中預設是沒有mysql,因為現在已經用mariadb代替mysql了。安裝mysql rpm包 rpm ivh mysql57 community release el7 11.noarch.rpm 安裝mysql yum install mysql community se...

Centos 7 使用yum安裝mysql 5 7

wget 2 安裝mysql yum y install mysql57 community release el7 10.noarch.rpm yum y install mysql community server 3 啟動mysql systemctl start mysqld.service...