Reputation: 235
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"
Upvotes: 0
Views: 544
Reputation: 3516
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
Upvotes: 0
Reputation: 13755
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
Upvotes: 1