#! /bin/bash
# 2023年7月10日23:49:10
# auto install mysql database
# version v2
# by author jie
#####################################
echo
"定義變數"
yum_repo_base=
""yum_repo_epel=
""mysql_ver=
"mysql-5.6.45.tar.gz"
mysql_mc=
"mysql-5.6.45"
mysql_yum=
"yum -y install"
mysql_yilai=
"git gcc gcc-c++ ncurses ncurses-devel make cmake libaio bison openssl openssl-devel"
mysql_url=
""mysql_basedir=
"/usr/local/mysql/"
mysql_datadir=
"/data/mysql/"
mysql_cnf=
"/etc/my.cnf"
echo
"安裝網易源及epel源"
wget -p /etc/yum.repos.d $yum_repo_base
wget -o /etc/yum.repos.d/epel.repo $yum_repo_base
yum clean all
yum makecache
echo
"安裝軟體依賴環境"
$mysql_yum
$mysql_yilai
echo
wget -c $mysql_url
tar -zxvf $mysql_ver
cd$mysql_mc
echo
"建立資料庫安裝base目錄"
mkdir -p $mysql_basedir
echo
"建立資料目錄"
mkdir -p $mysql_datadir
useradd -m -s /sbin/nologin -r mysql
chown -r mysql. $mysql_datadir
pwdecho
"預編譯"
cmake . -dcmake_install_prefix=
$mysql_basedir \
-dmysql_unix_addr=/tmp/mysql.sock \
-dmysql_datadir=
$mysql_datadir \
-dsysconfdir=/etc \
-dmysql_user=mysql \
-dmysql_tcp_port=3306 \
-dwith_xtradb_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_partition_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwith_myisam_storage_engine=1 \
-dwith_readline=1 \
-denabled_local_infile=1 \
-dwith_extra_charsets=1 \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci \
-dextra_charsets=all \
-dwith_big_tables=1 \
-dwith_debug=0
echo
"編譯及安裝"
make
&&make
install
echo
"新建啟動二進位制檔案"
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
echo
"給二進位制檔案加可執行檔案"
chmod +x /etc/init.d/mysqld
echo
"配置my.cnf檔案"
cat>
$mysql_basedir/my.cnf<<
eof[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
user = mysql
tmpdir = /tmp
basedir = /usr/local/mysql/
datadir = /data/mysql/
pid-file = /data/mysql/mysql.pid
socket = /tmp/mysql.sock
[mysql_safe]
log-error = /data/mysql/error.log
eofecho
"複製my.cnf"
cp -rf $mysql_basedir/my.cnf $mysql_cnf
chmod 755 $mysql_cnf
echo
"初始化資料庫"
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=
$mysql_basedir --datadir=
$mysql_datadir --defaults-file=
$mysql_cnf
echo
"設定環境變數"
echo
"export path=$path:/usr/local/mysql/bin"
>> /etc/profile
source /etc/profile
echo
$path
echo
"將mysql設定為系統服務"
chkconfig --level 35 mysqld on
chkconfig --add mysqld
echo
"關閉啟動資料庫"
/etc/init.d/mysqld start
echo
"檢視程序"
ps -ef |
grep mysqld
echo
"檢視埠"
netstat -ntlp |
grep mysqld
echo
"檢視mysql執行狀態"
systemctl status mysqld
驗證:!
[在這c裡插入描述]
(**~~僅供個人學習參考~~ **
Linux一鍵安裝
1 使用putty或類似的ssh工具登陸vps或伺服器 登陸後執行 screen s lnmp 如果提示screen command not found 命令不存在可以執行 yum install screen 或 apt get install screen安裝,詳細內容參考screen教程。如需...
lnmp一鍵安裝linux
系統需求 lnmp一鍵安裝包 v1.3 已經在 photonvps vultr 遨遊主機 oneasiahost新加坡vps 搬瓦工 budgetvm digitalocean locvps linode diahosting 瑞豪開源 kvmla 景文互聯 ramnode hostigation ...
Linux下一鍵安裝caffe opencv
官網 選linux版本 選python3.6版本的 可以看旁邊版本提示,萬一以後你下的不是4.3.1要改的哈 然後!安裝完了提示successful 它說要配置環境 你打yes就可以了 然後!重要!放上清華源的conda映象 conda config add channels conda confi...