新版 给 mysql 添加管理员的 sql语句

SET @NEWUSER='master';
SET @NEWPASS='password';


SELECT @FF:=GROUP_CONCAT(column_name) from information_schema.columns where TABLE_NAME='User' and COLUMN_NAME not in('Host','User','Password');


set @SQL=CONCAT('insert into mysql.user select \'%\',\'',@NEWUSER,'\',PASSWORD(\'',@NEWPASS,'\'),',@FF,' from mysql.user where user=\'root\';') ;


PREPARE stmt from @SQL;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
flush privileges;


select * from mysql.user;

你可能感兴趣的:(mysql,管理员,其他)