本文主要讲述mac下5.6/5.7/8.0用tar.gz方式安装的mysql数据库,并晒出简单的shell脚本和执行方式,自测可以通过

主要功能点:

mysql-install.sh:安装,配置环境变量,开机自启动,修改默认密码

mysql-config.sh:建库,使用sql文件还原,创建用户和授权

mysql-backup.sh:备份,清楚历史备份

版本:

mac---macOS Mojave 10.14 18A391 Lazy Installer.cdr

mysql 5.6---5.6.33

mysql 5.7---5.7.31

mysql 8.0---8.0.22

使用说明:

1-下载下来的tar.gz文件需要先解压,然后重新命名为mysql.tar.gz

2-5.7和8.0版本需要预先在mysql文件夹下创建data的文件夹

3-解压脚本:

例如5.7版本的tar.gz文件:

解压到tar.gz包的同级目录下:

 sudo tar xvf mysql-5.7.31-macos10.14-x86_64.tar.gz

修改文件夹名称:

sudo mv mysql-5.7.31-macos10.14-x86_64 mysql

如果5.7和8.0版本需要在mysql文件夹下创建data目录

切入mysql文件夹下

sudo mkdir data

注意:切到mysql的同级目录下,然后压缩文件夹

sudo tar cvf mysql.tar.gz mysql

4-下载

https://downloads.mysql.com/archives/community/

5.6

5.7

8.0

5-文件列表

mysql-install.sh:安装脚本,需要com.oracle.oss.mysql.mysqld.plist,my.cnf,mysql.tar.gz等文件(mysql.tar.gz为安装文件,my.cnf为配置文件,com.oracle.oss.mysql.mysqld.plist为开机自启动脚本)

执行方式:

sudo ./mysql-install.sh

执行结果:

mysql-config.sh:配置文件,需要sql文件(.sql文件为还原数据库的sql,不包括创建用户和授权)

执行方式:

sudo ./mysql-config.sh

执行结果:

mysql-backup.sh:备份文件,备份结果在该脚本所在目录

执行方式:

sudo ./mysql-backup.sh

执行结果:

脚本放送:

5.6-mysql-install.sh

#!/bin/bash#the parameters
_install_path=/usr/local_mysql_path=/usr/local/mysql_my_path=/etc_root_password=ABCDEFG_cur_path=$(cd $(dirname $0); pwd)_comp_file=$_cur_path/mysql.tar.gz_my_file=$_cur_path/my.cnf_install_log=$_cur_path/install_log.txt_bin_path=$_mysql_path/bin_self_start_dir=/Library/LaunchDaemons_self_start_file=com.oracle.oss.mysql.mysqld.plist
################################decompression the file
tar vxf $_comp_file -C $_install_pathif [ ! $? -eq 0 ]; thenecho 'Unzip failed!'>>$_install_logecho 'Unzip failed!'exit 1
ficd $_mysql_path
chown -R _mysql .
chgrp -R _mysql .#put the my.cnf to
cp $_my_file $_mysql_path/my.cnfif [ ! $? -eq 0 ]; thenecho 'Fail to copy my.cnf!'>>$_install_logecho 'Fail to copy my.cnf!'exit 3
fi##init mysql
./scripts/mysql_install_db --user=_mysql --basedir=$_mysql_path --datadir=$_mysql_path/data
if [ ! $? -eq 0 ]; thenecho 'Install Failed!'>>$_install_logecho 'Install Failed!'exit 5
fi##set path environment
echo export PATH=${PATH}:/usr/local/mysql/bin >> ~/.bash_profile
echo source ~/.bash_profile >> ~/.zshrc
source ~/.bash_profileif [ ! $? -eq 0 ]; thenecho 'Set Environment Path Failed!'>>$_install_logecho 'Set Environment Path Failed!'exit 6
fi##start mysql
$_mysql_path/support-files/mysql.server startif [ ! $? -eq 0 ]; thenecho 'Start mysql server Failed!'>>$_install_logecho 'Start mysql server Failed!'exit 7
ficp $_cur_path/$_self_start_file $_self_start_dir
launchctl load -w $_self_start_dir/$_self_start_fileif [ ! $? -eq 0 ]; thenecho 'Set self-starting Failed!'>>$_install_logecho 'Set self-starting Failed!'exit 8
fi##modify the password of root
./bin/mysqladmin -u root password $_root_passwordif [ ! $? -eq 0 ]; thenecho 'Fail to reset the password of root!'>>$_install_logecho 'Fail to reset the password of root!'exit 9
fimysql -u root -p$_root_password << EOFdrop user ''@'localhost';drop user root@'::1';drop user root@127.0.0.1;GRANT all privileges ON *.* TO root@"%" IDENTIFIED BY '$_root_password' with grant option;
EOFif [ ! $? -eq 0 ]; thenecho 'Fail to clear the unuse user!'>>$_install_logecho 'Fail to clear the unuse user!'exit 10
fiecho 'Successfully!'>>$_install_log
echo 'Successfully!'
exit 0

5.6-my.cnf

[mysqld]
based = /usr/local/mysq
datadir = /usr/local/mysql/data
skip_name_resolve = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server=utf8
interactive_timeout=2880000
wait_timeout=2880000
event_scheduler=1
innodb_buffer_pool_size=512M
lower_case_table_names=1
log-error=/usr/local/mysql/data/error.log
pid-file=/usr/local/mysql/data/mysql.pid
user=mysql
tmpdir=/tmp[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/lib/mysql/mysqld.pid

5.6-mysql-config.sh

#!/bin/bash
#############################################################
# Parameters Definitions
#############################################################
_cur_path=$(cd $(dirname $0); pwd)#the sql file to restore
_sql_script=$_cur_path/thesql.sql#host name
_host_name=localhost#password of root
_root_password=ABCDEFG#database name
_db_name=thedb#user name to connect to the database
_db_user=theuser#password of user
_db_password=123456#Default Permissions
_permission_string="create temporary tables,delete,execute,insert,lock tables,select,show view,update"#error fla
_error_flag=no_mysql_path=/usr/local/mysql_bin_path=$_mysql_path/bin######################################################check the restore file exist
if [ ! -e $_sql_script ]; thenecho 'SQL Script: invalid file.'exit 1
fi ######################################################mysql root user option
_root_user_option=""
if [ $_root_password ]; then_root_user_option="-p$_root_password"
elseecho "Empty mysql root password."
fi####################################################
cd /usr/local/mysql/bin#create database
$_bin_path/mysql -h $_host_name -u root $_root_user_option -e "create database if not exists $_db_name default charset utf8 collate utf8_general_ci"
if [ ! $? -eq 0 ]; thenecho "Failed to create the database."exit 2
fi#restore
$_bin_path/mysql -h $_host_name -u root $_root_user_option --default-character-set=utf8 $_db_name<$_sql_script
if [ ! $? -eq 0 ]; thenecho "Failed to create the database schema."exit 3
fi#####################################################the database user
$_bin_path/mysql -h $_host_name -u root $_root_user_option -e "grant $_permission_string on $_db_name.* to $_db_user@'%' identified by '$_db_password'"
if [ ! $? -eq 0 ]; thenecho "Failed to set database user permissions."exit 4
fi$_bin_path/mysql -h $_host_name -u root $_root_user_option -e "grant $_permission_string on $_db_name.* to $_db_user@'localhost' identified by '$_db_password'"
if [ ! $? -eq 0 ]; thenecho "Failed to set database user permissions(localhost)."exit 5
fiecho "Database setup completed."
exit 0

5.6-mysql-backup.sh

#!/bin/bash###############################
# parameters.
###############################
_cur_path=$(cd $(dirname $0); pwd)#path to save the sql
_file_path=$_cur_path#host name
_host_name=localhost#database name
_db_name=thedb#root password
_root_passwd=ABCDEFG#days to keep backup file
_keep_days=2_mysql_path=/usr/local/mysql_bin_path=$_mysql_path/bin
###############################
# default parameters.
###############################_thedate=`date +'%Y%m%d'`
_thetime=`date +'%Y-%m-%d %H:%M:%S'`#backup log
_backup_log=$_file_path/backup_log.txt#parameters to backup
_backup_set=' --default-character-set=utf8 --add_drop-table --allow-keywords --force --single-transaction --no-autocommit -c --opt --triggers -R --hex-blob '#file name of sql
_sql_file=$_file_path/$_db_name'_'$_thedate.sql#out-dated date
_var=-v-#$_keep_days#d_rm_date=`date ${_var//#/} +%Y%m%d`#out-dated sql file name
_rm_file=$_file_path/$_db_name'_'$_rm_date.sql#mysql root user option
_root_user_option=""
if [ $_root_passwd ]; then_root_user_option="-p$_root_passwd"
fi###############################
# check
###############################echo $_thetime>>$_backup_log
echo -e 'backup log:'>>$_backup_log#check the file path
if [ ! -d $_file_path ]; thenmkdir -p "$_file_path"
fi
if [ ! $? -eq 0 ]; thenecho $_thetime': Create the file path failed.'>>$_backup_logecho 'Create the file path failed.'exit 1
fi###############################
# backup
###############################$_bin_path/mysqldump $_backup_set -h $_host_name -u root $_root_user_option $_db_name>$_sql_fileif [ ! $? -eq 0 ]; thenecho $_thetime': Backup failed.'>>$_backup_logecho 'Backup failed.'exit 2
fi###############################
# clear out-dated sql
###############################if [[ $_keep_days -eq 0 && $_keep_days='no' ]]; thenecho 'No need to delete the out-dated sql file'>>$_backup_log
elserm -f $_rm_fileecho $_thetime': Clear the out-dated sql file!'>>$_backup_log
fiif [ ! $? -eq 0 ]; thenexit 3
fiecho -e '\n\n'>>$_backup_log
echo 'Backup Successfully!'>>$_backup_log
echo 'Backup Successfully!'exit 0

5.7-mysql-install.sh

#!/bin/bash#the parameters
_install_path=/usr/local_mysql_path=/usr/local/mysql_my_path=/etc_root_password=ABCDEFG_cur_path=$(cd $(dirname $0); pwd)_comp_file=$_cur_path/mysql.tar.gz_my_file=$_cur_path/my.cnf_install_log=$_cur_path/install_log.txt_bin_path=$_mysql_path/bin_data_path=$_mysql_path/data_user=$USER_self_start_dir=/Library/LaunchDaemons_self_start_file=com.oracle.oss.mysql.mysqld.plist ################################decompression the file
tar vxf $_comp_file -C $_install_pathif [ ! $? -eq 0 ]; thenecho 'Unzip failed!'>>$_install_logecho 'Unzip failed!'exit 1
fi#put the my.cnf to /etc
cp $_my_file $_my_path/my.cnfif [ ! $? -eq 0 ]; thenecho 'Fail to copy my.cnf!'>>$_install_logecho 'Fail to copy my.cnf!'exit 2
fi#set permission
cd $_install_path
sudo chown -R $_user:wheel mysql##init mysql
cd $_bin_path
./mysqld --initialize --user=$_userif [ ! $? -eq 0 ]; thenecho 'Init Failed!'>>$_install_logecho 'Init Failed!'exit 3
fichmod -R a+rwx $_data_pathif [ ! $? -eq 0 ]; thenecho 'Set permission to data path Failed!'>>$_install_logecho 'Set permission to data path Failed!'exit 4
fi$_mysql_path/support-files/mysql.server startif [ ! $? -eq 0 ]; thenecho 'Start mysql Failed!'>>$_install_logecho 'Start mysql Failed!'exit 5
fi##set path environment
echo export PATH=${PATH}:$_bin_path >> ~/.bash_profile
echo source ~/.bash_profile >> ~/.zshrc
source ~/.bash_profile
alias mysql=$_bin_path/mysqlif [ ! $? -eq 0 ]; thenecho 'Set Environment Path Failed!'>>$_install_logecho 'Set Environment Path Failed!'exit 6
fi#set self-startingcp $_cur_path/$_self_start_file $_self_start_dir
launchctl load -w $_self_start_dir/$_self_start_fileif [ ! $? -eq 0 ]; thenecho 'Set self-starting Failed!'>>$_install_logecho 'Set self-starting Failed!'exit 7
fi_tmp_passwd=`grep 'temporary password' $_data_path/error.log`
_tmp_passwd=${_tmp_passwd:0-12:12}mysql -u root -p"$_tmp_passwd" --connect-expired-password << EOFALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '$_root_password';
EOF
if [ ! $? -eq 0 ]; thenecho 'Fail to reset the password of root!'>>$_install_logecho 'Fail to reset the password of root!'exit 8
fiecho 'Successfully!'>>$_install_log
echo 'Successfully!'
exit 0

5.7-my.cnf

[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
skip_name_resolve = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server=utf8
interactive_timeout=2880000
wait_timeout=2880000
event_scheduler=1
innodb_buffer_pool_size=512M
log-error=/usr/local/mysql/data/error.log
pid-file=/usr/local/mysql/data/mysql.pid
user=mysql
tmpdir=/tmp
socket=/tmp/mysql.sock

5.7-mysql-config.sh

#!/bin/bash
#############################################################
# Parameters Definitions
#############################################################
_cur_path=$(cd $(dirname $0); pwd)#the sql file to restore
_sql_script=$_cur_path/thesql.sql#host name
_host_name=localhost#password of root
_root_password=ABCDEFG#database name
_db_name=thedb#user name to connect to the database
_db_user=theuser#password of user
_db_password=123456#Default Permissions
_permission_string="create temporary tables,delete,execute,insert,lock tables,select,show view,update"#error fla
_error_flag=no_mysql_path=/usr/local/mysql_bin_path=$_mysql_path/bin
######################################################check the restore file exist
if [ ! -e $_sql_script ]; thenecho 'SQL Script: invalid file.'exit 1
fi ######################################################mysql root user option
_root_user_option=""
if [ $_root_password ]; then_root_user_option="-p$_root_password"
elseecho "Empty mysql root password."
fi#####################################################create database
$_bin_path/mysql -h $_host_name -u root $_root_user_option -e "create database if not exists $_db_name default charset utf8 collate utf8_general_ci"
if [ ! $? -eq 0 ]; thenecho "Failed to create the database."exit 2
fi#restore
$_bin_path/mysql -h $_host_name -u root $_root_user_option --default-character-set=utf8 $_db_name<$_sql_script
if [ ! $? -eq 0 ]; thenecho "Failed to create the database schema."exit 3
fi#####################################################the database user
$_bin_path/mysql -h $_host_name -u root $_root_user_option -e "grant $_permission_string on $_db_name.* to $_db_user@'%' identified by '$_db_password'"
if [ ! $? -eq 0 ]; thenecho "Failed to set database user permissions."exit 4
fi$_bin_path/mysql -h $_host_name -u root $_root_user_option -e "grant $_permission_string on $_db_name.* to $_db_user@'localhost' identified by '$_db_password'"
if [ ! $? -eq 0 ]; thenecho "Failed to set database user permissions(localhost)."exit 5
fiecho "Database setup completed."
exit 0

5.7-mysql-backup.sh

#!/bin/bash###############################
# parameters.
###############################
_cur_path=$(cd $(dirname $0); pwd)#path to save the sql
_file_path=$_cur_path#host name
_host_name=localhost#database name
_db_name=thedb#root password
_root_passwd=ABCDEFG#days to keep backup file
_keep_days=2_mysql_path=/usr/local/mysql_bin_path=$_mysql_path/bin###############################
# default parameters.
###############################_thedate=`date +'%Y%m%d'`
_thetime=`date +'%Y-%m-%d %H:%M:%S'`#backup log
_backup_log=$_file_path/backup_log.txt#parameters to backup
_backup_set=' --default-character-set=utf8 --add_drop-table --allow-keywords --force --single-transaction --no-autocommit -c --opt --triggers -R --hex-blob '#file name of sql
_sql_file=$_file_path/$_db_name'_'$_thedate.sql#out-dated date
_var=-v-#$_keep_days#d_rm_date=`date ${_var//#/} +%Y%m%d`#out-dated sql file name
_rm_file=$_file_path/$_db_name'_'$_rm_date.sql#mysql root user option
_root_user_option=""
if [ $_root_passwd ]; then_root_user_option="-p$_root_passwd"
fi###############################
# check
###############################echo $_thetime>>$_backup_log
echo -e 'backup log:'>>$_backup_log#check the file path
if [ ! -d $_file_path ]; thenmkdir -p "$_file_path"
fi
if [ ! $? -eq 0 ]; thenecho $_thetime': Create the file path failed.'>>$_backup_logecho 'Create the file path failed.'exit 1
fi###############################
# backup
###############################
$_bin_path/mysqldump $_backup_set -h $_host_name -u root $_root_user_option $_db_name>$_sql_fileif [ ! $? -eq 0 ]; thenecho $_thetime': Backup failed.'>>$_backup_logecho 'Backup failed.'exit 2
fi###############################
# clear out-dated sql
###############################if [[ $_keep_days -eq 0 && $_keep_days='no' ]]; thenecho 'No need to delete the out-dated sql file'>>$_backup_log
elserm -f $_rm_fileecho $_thetime': Clear the out-dated sql file!'>>$_backup_log
fiif [ ! $? -eq 0 ]; thenexit 3
fiecho -e '\n\n'>>$_backup_log
echo 'Backup Successfully!'>>$_backup_log
echo 'Backup Successfully!'exit 0

8.0-mysql-install.sh

#!/bin/bash#the parameters
_install_path=/usr/local_mysql_path=/usr/local/mysql_my_path=/etc_root_password=ABCDEFG_cur_path=$(cd $(dirname $0); pwd)_comp_file=$_cur_path/mysql.tar.gz_my_file=$_cur_path/my.cnf_install_log=$_cur_path/install_log.txt_bin_path=$_mysql_path/bin_data_path=$_mysql_path/data_user=$USER_self_start_dir=/Library/LaunchDaemons_self_start_file=com.oracle.oss.mysql.mysqld.plist
################################decompression the file
tar vxf $_comp_file -C $_install_pathif [ ! $? -eq 0 ]; thenecho 'Unzip failed!'>>$_install_logecho 'Unzip failed!'exit 1
fi#put the my.cnf to /etc
cp $_my_file $_my_path/my.cnfif [ ! $? -eq 0 ]; thenecho 'Fail to copy my.cnf!'>>$_install_logecho 'Fail to copy my.cnf!'exit 2
fi#set permission
cd $_install_path
sudo chown -R $_user:wheel mysql##init mysql
cd $_bin_path
./mysqld --initialize --user=$_userif [ ! $? -eq 0 ]; thenecho 'Init Failed!'>>$_install_logecho 'Init Failed!'exit 3
fichmod -R a+rwx $_data_pathif [ ! $? -eq 0 ]; thenecho 'Set permission to data path Failed!'>>$_install_logecho 'Set permission to data path Failed!'exit 4
fi$_mysql_path/support-files/mysql.server startif [ ! $? -eq 0 ]; thenecho 'Start mysql Failed!'>>$_install_logecho 'Start mysql Failed!'exit 5
fi##set path environment
echo export PATH=${PATH}:$_bin_path >> ~/.bash_profile
echo source ~/.bash_profile >> ~/.zshrc
source ~/.bash_profile
alias mysql=$_bin_path/mysqlif [ ! $? -eq 0 ]; thenecho 'Set Environment Path Failed!'>>$_install_logecho 'Set Environment Path Failed!'exit 6
ficp $_cur_path/$_self_start_file $_self_start_dir
launchctl load -w $_self_start_dir/$_self_start_fileif [ ! $? -eq 0 ]; thenecho 'Set self-starting Failed!'>>$_install_logecho 'Set self-starting Failed!'exit 7
fi_tmp_passwd=`grep 'temporary password' $_data_path/error.log`
_tmp_passwd=${_tmp_passwd:0-12:12}mysql -u root -p"$_tmp_passwd" --connect-expired-password << EOFALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '$_root_password';
EOF
if [ ! $? -eq 0 ]; thenecho 'Fail to reset the password of root!'>>$_install_logecho 'Fail to reset the password of root!'exit 8
fiecho 'Successfully!'>>$_install_log
echo 'Successfully!'
exit 0

8.0-my.cnf

[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
skip_name_resolve = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server=utf8
interactive_timeout=2880000
wait_timeout=2880000
event_scheduler=1
innodb_buffer_pool_size=512M
log-error=/usr/local/mysql/data/error.log
pid-file=/usr/local/mysql/data/mysql.pid
user=mysql
tmpdir=/tmp
socket=/tmp/mysql.sock

8.0-mysql-config.sh

#!/bin/bash
#############################################################
# Parameters Definitions
#############################################################
_cur_path=$(cd $(dirname $0); pwd)#the sql file to restore
_sql_script=$_cur_path/thesql.sql#host name
_host_name=localhost#password of root
_root_password=ABCDEFG#database name
_db_name=thedb#user name to connect to the database
_db_user=theuser#password of user
_db_password=123456#Default Permissions
_permission_string="create temporary tables,delete,execute,insert,lock tables,select,show view,update"#error fla
_error_flag=no_mysql_path=/usr/local/mysql_bin_path=$_mysql_path/bin
######################################################check the restore file exist
if [ ! -e $_sql_script ]; thenecho 'SQL Script: invalid file.'exit 1
fi ######################################################mysql root user option
_root_user_option=""
if [ $_root_password ]; then_root_user_option="-p$_root_password"
elseecho "Empty mysql root password."
fi#####################################################create database
$_bin_path/mysql -h $_host_name -u root $_root_user_option -e "create database if not exists $_db_name default charset utf8 collate utf8_general_ci"
if [ ! $? -eq 0 ]; thenecho "Failed to create the database."exit 2
fi#restore
$_bin_path/mysql -h $_host_name -u root $_root_user_option --default-character-set=utf8 $_db_name<$_sql_script
if [ ! $? -eq 0 ]; thenecho "Failed to create the database schema."exit 3
fi#####################################################the database user
$_bin_path/mysql -h $_host_name -u root $_root_user_option << EOF create user $_db_user@'%' identified by '$_db_password';grant $_permission_string on $_db_name.* to $_db_user@'%';
EOF
if [ ! $? -eq 0 ]; thenecho "Failed to set database user permissions."exit 4
fi$_bin_path/mysql -h $_host_name -u root $_root_user_option << EOFcreate user $_db_user@'localhost' identified by '$_db_password';grant $_permission_string on $_db_name.* to $_db_user@'localhost';
EOF
if [ ! $? -eq 0 ]; thenecho "Failed to set database user permissions(localhost)."exit 5
fiecho "Database setup completed."
exit 0

8.0-mysql-backup.sh

#!/bin/bash###############################
# parameters.
###############################
_cur_path=$(cd $(dirname $0); pwd)#path to save the sql
_file_path=$_cur_path#host name
_host_name=localhost#database name
_db_name=thedb#root password
_root_passwd=ABCDEFG#days to keep backup file
_keep_days=2_mysql_path=/usr/local/mysql_bin_path=$_mysql_path/bin###############################
# default parameters.
###############################_thedate=`date +'%Y%m%d'`
_thetime=`date +'%Y-%m-%d %H:%M:%S'`#backup log
_backup_log=$_file_path/backup_log.txt#parameters to backup
_backup_set=' --default-character-set=utf8 --add_drop-table --allow-keywords --force --single-transaction --no-autocommit -c --opt --triggers -R --hex-blob '#file name of sql
_sql_file=$_file_path/$_db_name'_'$_thedate.sql#out-dated date
_var=-v-#$_keep_days#d_rm_date=`date ${_var//#/} +%Y%m%d`#out-dated sql file name
_rm_file=$_file_path/$_db_name'_'$_rm_date.sql#mysql root user option
_root_user_option=""
if [ $_root_passwd ]; then_root_user_option="-p$_root_passwd"
fi###############################
# check
###############################echo $_thetime>>$_backup_log
echo -e 'backup log:'>>$_backup_log#check the file path
if [ ! -d $_file_path ]; thenmkdir -p "$_file_path"
fi
if [ ! $? -eq 0 ]; thenecho $_thetime': Create the file path failed.'>>$_backup_logecho 'Create the file path failed.'exit 1
fi###############################
# backup
###############################
$_bin_path/mysqldump $_backup_set -h $_host_name -u root $_root_user_option $_db_name>$_sql_fileif [ ! $? -eq 0 ]; thenecho $_thetime': Backup failed.'>>$_backup_logecho 'Backup failed.'exit 2
fi###############################
# clear out-dated sql
###############################if [[ $_keep_days -eq 0 && $_keep_days='no' ]]; thenecho 'No need to delete the out-dated sql file'>>$_backup_log
elserm -f $_rm_fileecho $_thetime': Clear the out-dated sql file!'>>$_backup_log
fiif [ ! $? -eq 0 ]; thenexit 3
fiecho -e '\n\n'>>$_backup_log
echo 'Backup Successfully!'>>$_backup_log
echo 'Backup Successfully!'exit 0

com.oracle.oss.mysql.mysqld.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict><key>Label</key>             <string>com.oracle.oss.mysql.mysqld</string><key>Disabled</key>          <false/><key>RunAtLoad</key>         <true/><key>KeepAlive</key>         <true/><key>SessionCreate</key>     <true/><key>LaunchOnlyOnce</key>    <false/><key>UserName</key>          <string>_mysql</string><key>GroupName</key>         <string>_mysql</string><key>ExitTimeOut</key>       <integer>600</integer><key>Program</key>           <string>/usr/local/mysql/bin/mysqld</string><key>ProgramArguments</key><array><string>/usr/local/mysql/bin/mysqld</string><string>--user=_mysql</string><string>--basedir=/usr/local/mysql</string><string>--datadir=/usr/local/mysql/data</string></array><key>WorkingDirectory</key>  <string>/usr/local/mysql</string>
</dict>
</plist>

mac上mysql.tar.gz的安装图解相关推荐

  1. Mac OS X 下 TAR.GZ 方式安装 MySQL

    Mac OS X 下 TAR.GZ 方式安装 MySQL 注意: 本篇文章适用与 MySQL 5.6 版本的安装, 但已不再适用 5.7 的安装, 5.7 的安装方式请参见:<Mac OS X ...

  2. Mac OS X 下 TAR.GZ 方式安装 MySQL5.6

    为什么80%的码农都做不了架构师?>>>    Mac OS X 下 TAR.GZ 方式安装 MySQL 注意: 本篇文章适用与 MySQL 5.6 版本的安装, 但已不再适用 5. ...

  3. mac 上mysql怎么卸载不了_mac上mysql怎么卸载不了

    mac上mysql卸载不了的解决办法:首先打开终端窗口:然后使用mysqldump备份数据库:接着停止数据库服务器:最后依次执行命令"sudo rm /usr/local/mysql...& ...

  4. mac下mysql的DMG格式安装卸载方法

    mac下mysql的DMG格式安装内有安装文件,却没有卸载文件--很郁闷的事. 网上搜了一下,发现给的方法原来得手动去删. 很多文章记述要删的文件不完整,后来在 stackoverflow 这里发现了 ...

  5. centos7安装mysql .gz_转:centos7安装mysql.tar.gz

    ** 由于我的文件夹名字为mysql5.7所以转载后修改过 ** 之前用的rpm安装的每次安装都是最新的,,,导致每次版本不统一... 现在用tar包安装5.7.22和5.7.20一样的   5.7. ...

  6. Centos7 - mysql 5.5.62 tar.gz 方式安装

    安装准备 Mariadb 去除 由于CentOS7自带的是 Mariadb, 所以先来删除他吧... 1. 查找版本 # rpm -qa|grep mariadb 执行命令后会出现类似 MariaDB ...

  7. mac上mysql关闭不了了_python操作mysql数据库

    Python 标准数据库接口为 Python DB-API,Python DB-API为开发人员提供了数据库应用编程接口. Python 数据库接口支持非常多的数据库,你可以选择适合你项目的数据库: ...

  8. 在linux上MySQL的三种安装方式

    安装MySQL的方式常见的有三种: 方式一:rpm安装 (1) 操作系统发行商提供的 (2) MySQL官方提供的(版本更新,修复了更多常见BUG)www.mysql.com/downloads 关于 ...

  9. 在Mac上为自己手动编译安装一套PHP7的开发环境

    首先你得去官网下载php7 beta1的版本 这里由于我是在mac上安装,所以就去下载linux相关的版本,地址也直接附上了 php7 beta1 windows版的官方也有发布详情猛戳:这里 解压安 ...

最新文章

  1. MPB:西农焦硕组-微生物生物地理学研究方法
  2. 使用CURL构建爬虫,抓取百度百科内容
  3. 2019.04.07 装饰器介绍
  4. 安卓scrollview无法滑动_安卓上线前,小光有话想对你们说
  5. FocalLoss的Caffe复现版
  6. A Juggling Algorithm (旋转交换)
  7. 3.4 小乌龟git使用说明
  8. 为真实硬件安装WDM驱动
  9. 科技论文格式和写作技巧
  10. Thumbnails压缩图片
  11. 新人如何快速融入团队
  12. 想知道你和她在网易云喜欢的音乐的重合率?
  13. easyui分页查询为什么会有下拉框_Easyui 添加分页组件_EasyUI 教程
  14. 《Hibernate上课笔记》----class4----Hibernate继承关系映射实现详解
  15. # Windows下关于安装Geany编辑器过程中的一点小发现(可能对初次安装的人有用)
  16. java applet 一个简单的例子(applet+html)
  17. Java项目:Springboot实现的一个简单博客管理系统
  18. 基于目标检测的海上舰船图像超分辨率研究
  19. C语言程序设计教程 北京邮电,C语言程序设计教程(第3版)/ 杨路明 9787563543403 北京邮电...
  20. phpcms视频库KU6改为优酷简单上传

热门文章

  1. css 图片彩色变黑白的(滤镜效果)
  2. 青少年趣味编程社区法则
  3. excel中如何对筛选后的单元格进行复制粘贴
  4. 26.XAPP1052源码实战1-DMA读写在线测试
  5. 电脑显示服务器未能登陆 无法加载用户配置,win7系统提示User Profile Service服务未能登录,无法加载用户配置文件的解决方法...
  6. 基于React的仿QQ音乐(移动端)
  7. 时隔一个月,讯飞星火大模型 V1.5 发布:星火 APP 登场,综合能力升级
  8. 浅析web api的json参数校验
  9. 如何修改 chrome 记住密码后自动填充表单的黄色背景?
  10. 股份有限公司的优缺点