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"
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
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
Try this at the end instead:
echo "$SQL" | mysql -u root -p
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.