0

I've been trying to correctly create a user and database for an hour using the bash script, but I'm still getting error messages. I paste the code below. I will be grateful for your help!

#!/bin/bash

username="useursur"
passworduser="dnfndfvjdngdg"

sudo mysql -u $username -p$passworduser <<EOF
    CREATE USER 'wpdb'@'localhost' IDENTIFIED BY 'fsafdasdfsadfasdf';
    CREATE DATABASE wpdb;
    GRANT ALL PRIVILEGES ON wpdb.* TO 'wpdb';
    FLUSH PRIVILEGES;
EOF

I changed the command to

sudo mysql -u $username -p$passworduser -e "CREATE USER 'wpdb'@'localhost' IDENTIFIED BY 'fsafdasdfsadfasdf';CREATE DATABASE wpdb;GRANT ALL PRIVILEGES ON wpdb.* TO 'wpdb';FLUSH PRIVILEGES;"

As a result I get this error:

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1133 (42000) at line 1: Can't find any matching row in the user table
5
  • 1
    What are the error messages? Commented Feb 18, 2020 at 22:00
  • stackoverflow.com/questions/32869275/… Commented Feb 18, 2020 at 22:02
  • mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'wpdb'@'localhost' Commented Feb 18, 2020 at 22:09
  • mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1133 (42000) at line 3: Can't find any matching row in the user table Commented Feb 18, 2020 at 22:12
  • Put the password in ~/.my.cnf, not on the commandline! Commented Feb 18, 2020 at 22:13

1 Answer 1

0

You need to specify the user and host when you GRANT.

GRANT ALL PRIVILEGES ON wpdb.* TO 'wpdb';

Should be:

GRANT ALL PRIVILEGES ON wpdb.* TO 'wpdb'@'localhost';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.