Using environment variables in mariadb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I want to script a rather simple create database operation. Thing is, I have to provide the password for that database. I would like to do this with an environment variable, but the simple approach dose not work:

mailpswd=charlie

mysql -u root -p

CREATE DATABASE mailfix;
CREATE USER 'mailfix'@'localhost' IDENTIFIED BY $mailpswd;
GRANT ALL PRIVILEGES ON `mailfix` . * TO 'mailfix'@'localhost';

Of course the mysql command needs the mysql root password, but that is as expected. But mysql will not process $mailpswd, not surprisingly.

I know I could create a file with these commands, sed the password into the file, then pipe thr file into mysql. I would rather do this directly without a temp file.

thanks


_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux