Roots Discourse

MAMP/Bedrock - Create database - HY000/2002 error

Hi there,

I am trying to make a bash script for creating a Wordpress website. In this script I am creating a project with Bedrock. After that I am trying to create a database with wp core install. Installing Bedrock and changing the .env file is not a problem. The only problem is that I can’t create a new database. Anyone got the same issue or knows a solution for this?

This is my bash script:

composer create-project roots/bedrock

shopt -s dotglob

mv bedrock/* .

rm -rf bedrock

shopt -s dotglob

sed -i “” “s/database_name/$1/g” .env
sed -i “” “s/database_user/root/g” .env
sed -i “” “s/database_password/root/g” .env
sed -i “” “s||localhost/$1/web|g” .env
sed -i “” “s|# DB_HOST=localhost|DB_HOST=|g” .env

echo “CREATE DATABASE $1; GRANT ALL ON $1.* TO ‘root’@‘localhost’;” | mysql -uroot -proot
wp core install --url=null --title=$1 --admin_user=admin --admin_password=admin


Mark Kruip

This topic was automatically closed after 42 days. New replies are no longer allowed.