0

Can anyone please tell me why I get this error after i run the command ?

root@server1:/home# ./dbcreate.sh db_team1 team1 team1password
ERROR 1133 (42000) at line 1: Can't find any matching row in the user table

This is the script I'm using.

#!/bin/bash

MYSQL=`which mysql`
ROOTPASSWD=mypassword

Q1="CREATE DATABASE IF NOT EXISTS $1;"
Q2="SET PASSWORD FOR '$2'@'localhost'= PASSWORD('$3');"
Q3="GRANT ALL PRIVILEGES ON $1.* TO '$2'@'localhost' IDENTIFIED BY '$3';"
Q4="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}${Q4}"

# Usage: $0 dbname dbuser dbpass"

$MYSQL -u root -p$ROOTPASSWD -e "$SQL"
0

3 Answers 3

1

It seems that you have the NO_AUTO_CREATE_USER mod enabled so GRANT cannot create a new user (also, creating users via GRANT may not work in 5.5 and 5.6). For more see here:

http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html#sqlmode_no_auto_create_user

Sign up to request clarification or add additional context in comments.

Comments

0

Add user creation statement before attempting to associate the user to database

CREATE USER your_username@localhost IDENTIFIED BY 'your_user_password';

This should resolve the problem

Comments

0

Try this at the end instead:

echo "$SQL" | mysql -u root -p

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.