简体   繁体   中英

Bash script create database

I've created a bash script to install Wordpress locally and create the database on my local machine.

This part should normally create the database

mysql -u $dbuser -p $dbpass "create database '$dbname'"

But I getting this error:

mysql: command not found

What am I doing wrong over here?

check mysql command exists or not:

$ sudo updatedb && locate bin/mysql
/usr/local/src/mysql/bin/mysql

then:

export PATH=$PATH:/usr/local/src/mysql/bin/

you can install updatedb and locate commands as:

#debian based
apt install mlocate
#centos
yum install mlocate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM