I have one bash script for installing wordpress and want to add also mysql installer to easly can install database
#!/bin/bash
dr=$1
db=$2
zDir="latest.zip"
wpInstall="https://wordpress.org/"$zDir
eval "mkdir -p "$dr" && cd "$dr" && wget "$wpInstall" && unzip "$zDir" && cp -r "$dr"/wordpress/* "$dr" && sudo chmod -R 0777 "$dr" && sudo chmod -R 0777 "$dr"/* && rm -rf "$dr"/wordpress && rm -f -r "$zDir" && echo WordPress installatio$
echo "CREATE DATABASE IF NOT EXISTS `"$db"` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" | mysql -u root -p
here I have one realy wierd problem:
When I run script like this:
$ ./install-wp.sh /var/www/test project_something
installer install wordpress, place all files on the rigt place but when start part with mysql I get 2 errors.
First is:
> ./install-wp.sh: line 13: project_something: command not found
and second after mysql passowrd is entered:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci' at line 1
How to fix this?
eval
is evil.printf
the evaluated string to understand your mistake. – xhienne Dec 17 '16 at 14:47&&
all over the place why not justset -e
? – ssdecontrol Dec 17 '16 at 15:16eval
here anyway – ssdecontrol Dec 17 '16 at 15:17