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

    script the creation of a database on CentOS7

    IT Discussion
    2
    4
    737
    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.olynykA
      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
      • scottalanmillerS
        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.olynykA
          alex.olynyk
          last edited by

          Thanks Scott! Works Perfectly!

          scottalanmillerS 1 Reply Last reply Reply Quote 3
          • scottalanmillerS
            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
            • 1 / 1
            • First post
              Last post