MySQL5 7版本部署

2021-09-29 17:42:35 字數 3069 閱讀 9410

1.安裝環境包

yum -y install \

gcc \

gcc-c++ \

ncurses \

ncurses-devel \

bison \

cmake

2.新增程式性使用者

useradd -s /sbin/nologin  mysql
3.遠端共享並建立掛載點掛載目錄

4.解壓縮包

tar zxvf mysql-5.7.17.tar.gz -c /opt/

tar zxvf boost_1_59_0.tar.gz -c /usr/local/

5.重新命名便於管理

cd /usr/local/

mv boost_1_59_0/ boost

6.cmake過程

cd mysql-5.7.17/

cmake \

-dcmake_install_prefix=/usr/local/mysql \

-dmysql_unix_addr=/usr/local/mysql/mysql.sock \

-dsysconfdir=/etc \

-dsystemd_pid_dir=/usr/local/mysql \

-ddefault_charset=utf8 \

-ddefault_collation=utf8_general_ci \

-dwith_innobase_storage_engine=1 \

-dwith_archive_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

-dwith_perfschema_storage_engine=1 \

-dmysql_datadir=/usr/local/mysql/data \

-dwith_boost=/usr/local/boost \

-dwith_systemd=1

7.編譯並安裝

make && make install
8.給mysql工作目錄賦予mysql程式性使用者的操作許可權

chown -r mysql.mysql /usr/local/mysql/
9.編輯mysql配置檔案

vi /etc/my.cnf

[client]

port = 3306

default-character-set=utf8

socket = /usr/local/mysql/mysql.sock

[mysql]

port = 3306

default-character-set=utf8

socket = /usr/local/mysql/mysql.sock

[mysqld]

user = mysql

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port = 3306

character_set_server=utf8

pid-file = /usr/local/mysql/mysqld.pid

socket = /usr/local/mysql/mysql.sock

server-id = 1

sql_mode=no_engine_substitution,strict_trans_tables,no_auto_create_user,no_auto_value_on_zero,no_zero_in_date,no_zero_date,error_for_division_by_zero,pipes_as_concat,ansi_quotes

10.給mysql配置檔案賦予mysql程式性使用者的操作許可權

chown mysql:mysql /etc/my.cnf
11.更改環境變數,以便於系統去進行識別

echo 'path=/usr/local/mysql/bin:/usr/local/mysql/lib:$path' >> /etc/profile

echo 'export path' >> /etc/profile

12.資料庫初始化

source /etc/profile
cd /usr/local/mysql/

bin/mysqld \

--initialize-insecure \

--user=mysql \

--basedir=/usr/local/mysql \

--datadir=/usr/local/mysql/data

cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/

systemctl daemon-reload

systemctl start mysqld

netstat -anpt | grep 3306

systemctl enable mysqld

mysqladmin -u root -p password "abc123"       //給root賬號設定密碼為abc123提示輸入的是原始密碼

mysql -u root -p

grant all privileges on *.* to 'root'@'%' identified by 'abc123' with grant option;

「skip-grant-tables」用來跳過密碼驗證的過程

update mysql.user set authentication_string=password('1') where user='root';

flush privileges;       重新整理

MySQL5 7版本安裝

解除安裝mariadb 1.rpm qa grep i mariadb 2.rpm e mariadb libs 5.5.52 1.el7.x86 64 nodeps 安裝mysql 1.tar xvf mysql 5.7.31 1.el7.x86 64.rpm bundle.tar 2.rpm i...

mysql5 7 版本登入問題

mysqld nt skip grant tables update mysql.user set authentication string root where user root flush privileges exit 這幾個命令就可以解決 關閉mysql 服務 在cmd 視窗1 輸入my...

Linux安裝mysql5 7版本

1.linux 安裝mysql 5.7順序 mysqladmin version 檢視版本號 mysql5.7 安裝在linux 中需要先初始化 mysqld initialize user mysql 檢視初始化密碼 cat var log mysqld.log 在 localhost 後面的為初...