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

    WP-CLI and database users

    IT Discussion
    wp-cli wp wordpress security
    5
    26
    2.0k
    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.
    • JaredBuschJ
      JaredBusch @1337
      last edited by JaredBusch

      @Pete-S said in WP-CLI and database users:

      And when you use -e you should have it after user and password so the SQL commands you want to execute comes after the -e.

      That was a once off artifact of me doing it on this system after the root password has been set.

      That was also the reason it did not work for me as I tried without the '

      1 1 Reply Last reply Reply Quote 0
      • 1
        1337 @JaredBusch
        last edited by 1337

        @JaredBusch said in WP-CLI and database users:

        @Pete-S said in WP-CLI and database users:

        And when you use -e you should have it after user and password so the SQL commands you want to execute comes after the -e.

        That was a once off artifact of me doing it on this system after the root password has been set.

        OK, so maybe this then:

        sudo mysql -e "CREATE USER $DB_USER@localhost IDENTIFIED by '$DB_PASS';"
        sudo mysql -e "GRANT ALL ON $DB_NAME.* TO $DB_USER@localhost;"
        sudo mysql -e "FLUSH PRIVILEGES;"
        
        JaredBuschJ 1 Reply Last reply Reply Quote 0
        • JaredBuschJ
          JaredBusch @1337
          last edited by

          @Pete-S said in WP-CLI and database users:

          I'm sure you know but you can also put more than one command in the execute string. ; is what separates the commands.

          My guides are specifically wrote lik this to clearly separate the commands that are used for the people following my guides to see every thing they are doing.

          1 Reply Last reply Reply Quote 1
          • JaredBuschJ
            JaredBusch @1337
            last edited by JaredBusch

            @Pete-S said in WP-CLI and database users:

            @JaredBusch said in WP-CLI and database users:

            @Pete-S said in WP-CLI and database users:

            And when you use -e you should have it after user and password so the SQL commands you want to execute comes after the -e.

            That was a once off artifact of me doing it on this system after the root password has been set.

            OK, so maybe this then:

            sudo mysql -e "CREATE USER $DB_USER@localhost IDENTIFIED by '$DB_PASS';"
            sudo mysql -e "GRANT ALL ON $DB_NAME.* TO $DB_USER@localhost;"
            sudo mysql -e "FLUSH PRIVILEGES;"
            

            right. Updating the guide. but half tempted to leave the single quotes everywhere it that causes no error in order to protect against spaces by others. Though I am using pwgen to do this.

            1 1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch
              last edited by JaredBusch

              Guide updated. I left the ' everywhere else.

              Of note, I had to drop the DB_NAME to 16 characters because it broke it longer. Even though current mariadb should accept much longer database names according to my quick google on the subject.

              1 Reply Last reply Reply Quote 0
              • 1
                1337 @JaredBusch
                last edited by

                @JaredBusch said in WP-CLI and database users:

                @Pete-S said in WP-CLI and database users:

                @JaredBusch said in WP-CLI and database users:

                @Pete-S said in WP-CLI and database users:

                And when you use -e you should have it after user and password so the SQL commands you want to execute comes after the -e.

                That was a once off artifact of me doing it on this system after the root password has been set.

                OK, so maybe this then:

                sudo mysql -e "CREATE USER $DB_USER@localhost IDENTIFIED by '$DB_PASS';"
                sudo mysql -e "GRANT ALL ON $DB_NAME.* TO $DB_USER@localhost;"
                sudo mysql -e "FLUSH PRIVILEGES;"
                

                right. Updating the guide. but half tempted to leave the single quotes everywhere it that causes no error in order to protect against spaces by others. Though I am using pwgen to to this.

                It's kind of f*cked up to have spaces in user names and passwords. Personally I don't use something unless it's specifically needed but either way works.

                1 Reply Last reply Reply Quote 0
                • 1
                • 2
                • 2 / 2
                • First post
                  Last post