My issue is that this:

mysql -u root -p newdb -e "UPDATE newdb_users SET user_login='newuser', user_pass='$P$BJ7HEXzUXBqB74hw0H9KD2QvdnlwGv1' WHERE user_login='admin';"

does not update the "user_pass" field, but entering this:

UPDATE newdb_users SET user_login='newuser', user_pass='$P$BJ7HEXzUXBqB74hw0H9KD2QvdnlwGv1' WHERE user_login='admin';

directly in the MySQL console does. What am I missing?

You have a -p flag for the password but nothing entered. If there is a root password then it should be prompting you. If there is not one remove the -p. You also should have a -D in front of database like this:

mysql -u root -ppassword -D newdb -e "UPDATE newdb_users SET user_login='newuser', user_pass='$P$BJ7HEXzUXBqB74hw0H9KD2QvdnlwGv1' WHERE user_login='admin';"

OR you can do this:

mysql -u root -p -e "use newdb \; UPDATE newdb_users SET user_login=\'newuser\', user_pass=\'$P$BJ7HEXzUXBqB74hw0H9KD2QvdnlwGv1\' WHERE user_login=\'admin\'\;"

You may also need the backslash in from of special characters like in the second example to tell the shell to ignore the normal use of the next character.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.