很期待,学习shell脚本,减少重复工作
自动安装配置mysql脚本:
#/bin/bash LOG_FILE=/home/hadoop1/log/installmysql.log function RpmMysql(){ key=$1 r=$(rpm -qa $key) if [ $r ]; then return 1 else return 0 fi } mysql="mysql-server" RpmMysql mysql r=$? if [ $r -eq 1 ] ; then echo "$mysql was installed" # mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak service mysqld start else echo "$mysql was not installed" yum install mysql mysql-server mysql-devel service mysqld start fi chown -R mysql:mysql /var/lib/mysql echo "install and start mysql success" #add user to mysql database user1=root password1=123456 host=192.168.0.200 user2=hadoop password2=123456 echo "INFORM:Enter database root password" #mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak #mysql -uroot -p </root/addroothadoop.sql> user1=root password1=123456 host=192.168.0.200 user2=hadoop password2=123456 echo "INFORM:Enter database root password" mysql -uroot -e "use mysql;update user set password =password(‘$password1‘) where user=‘$user1‘;insert ignore into mysql.user(User,Password)values(‘$user2‘,‘password2‘);grant all privileges on *.* to [email protected]‘%‘ identified by ‘$password2‘;flush privileges;" echo "configure done"
时间: 2024-11-09 04:58:11