Get the App
SLTechnology News&Howtos  ›  Servers  › 

Mysql installation script

Shulou Source: shulou.com Published: 2022-06-03 08:50:26 09月21日 Update

#! / bin/bash

Echo "# # MySQL installing.####"

Echo "- config my.cnf-"

Mv / etc/my.cnf / etc/my.cnf_date +% Y%m%d

SERVER_ID=ifconfig eth0 | grep inet | awk'{print $2}'| awk-F. '{print $3 $4}'

Mem=free-m | grep Mem | awk'{print $2}'

SIZE=$ [Mem*1/2]

Mysqldir=pwd

Cat > > / etc/my$ipaddr.cnf / etc/profile

Source / etc/profile

Echo "- initialize MySQL-"

${mysqldir} / mysql/bin/mysqld-initialize-- user=mysql-- basedir=$ {mysqldir} / mysql-- datadir=$ {mysqldir} / mysql/mysql_data/

Echo "- start MySQL-"

Cp ${mysqldir} / mysql/support-files/mysql.server / etc/init.d/mysqld

Ln-s ${mysqldir} / mysql/bin/mysql / usr/sbin/mysql

/ etc/init.d/mysqld start

# ${mysqldir} / mysql/bin/mysqladmin-u root password 'passw0rd'

# echo "- init password of MySQL-"

OLD_PWD=cat ${mysqldir} / mysql/log/mysql.log | grep "password is generated" | awk'{print $NF}'

${mysqldir} / mysql/bin/mysqladmin-u root-p$ {OLD_PWD} password 'admin@admin'

Echo "root password is: admin@admin"

Tags: Script Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Huawei Microsoft NVidia