script the creation of a database on CentOS7
-
I want to script the creation of a database on CentOS7. I know how to run the commands but what would I need to turn this into a script?
mysql -u root -p
create database db;
create user 'user'@'localhost' identified by 'password';
grant all on db.* to 'user'@'localhost';
flush privileges;
quit -
You start by putting the SQL commands (not the system ones) into a file. Traditionally this file is called something and ends with dot sql. So:
myserverdetails.sql
Then you just run it like this:
mysql -u root -p < myserverdetails.sql
-
Thanks Scott! Works Perfectly!
-
@alex.olynyk said in script the creation of a database on CentOS7:
Thanks Scott! Works Perfectly!
No problem. Done that one many a time.