ML
    • Register
    • Login
    • Search
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    script the creation of a database on CentOS7

    IT Discussion
    2
    4
    545
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • alex.olynyk
      alex.olynyk last edited by

      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

      1 Reply Last reply Reply Quote 1
      • scottalanmiller
        scottalanmiller last edited by

        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
        
        1 Reply Last reply Reply Quote 3
        • alex.olynyk
          alex.olynyk last edited by

          Thanks Scott! Works Perfectly!

          scottalanmiller 1 Reply Last reply Reply Quote 3
          • scottalanmiller
            scottalanmiller @alex.olynyk last edited by

            @alex.olynyk said in script the creation of a database on CentOS7:

            Thanks Scott! Works Perfectly!

            No problem. Done that one many a time.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post