config root man

Current Path : /home/usr.opt/mysql57/mysql-test/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/t/initialize-init-acls.test

--source include/big_test.inc
--source include/not_embedded.inc
--source include/have_no_undo_tablespaces.inc


let BASEDIR= `select @@basedir`;
let DDIR=$MYSQL_TMP_DIR/installdb_test;
let MYSQLD_LOG=$MYSQL_TMP_DIR/server.log;
let extra_args=--no-defaults --console --log-syslog=0 --loose-skip-auto_generate_certs --loose-skip-sha256_password_auto_generate_rsa_keys --skip-ssl --basedir=$BASEDIR --lc-messages-dir=$MYSQL_SHAREDIR;
let BOOTSTRAP_SQL=$MYSQL_TMP_DIR/tiny_bootstrap.sql;
let PASSWD_FILE=$MYSQL_TMP_DIR/password_file.txt;

--echo # We don't care about innodb warnings at this point
CALL mtr.add_suppression("InnoDB:");

--echo # shut server down
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--echo # Server is down


--echo #
--echo # Bug #20546898: MYSQLD --INIT-FILE DOESN\'T ACCEPT GRANT STATEMENTS
--echo #

--echo # create bootstrap file with ACL commands
write_file $BOOTSTRAP_SQL;
CREATE DATABASE test;
CREATE DATABASE grants_try;
CREATE USER u1@localhost;
CREATE USER u2@localhost;
CREATE USER u3@localhost;
ALTER USER u2@localhost IDENTIFIED BY 'haha';
GRANT SELECT, UPDATE ON grants_try.* TO u3@localhost;
REVOKE UPDATE ON grants_try.* FROM u3@localhost;
EOF

--echo # Run the server with --initialize --init-file
--exec $MYSQLD $extra_args --initialize --datadir=$DDIR --init-file=$BOOTSTRAP_SQL > $MYSQLD_LOG 2>&1

--echo extract the root password
--perl
  use strict;
  my $log= $ENV{'MYSQLD_LOG'} or die;
  my $passwd_file= $ENV{'PASSWD_FILE'} or die;
  my $FILE;
  open(FILE, "$log") or die;
  while (my $row = <FILE>)
  {
    if ($row =~ m/.*A temporary password is generated for root.localhost: ([^ \n][^ \n]*)/)
    {
      my $passwd=$1;
      print "password found\n";
      my $OUT_FILE;
      open(OUT_FILE, "> $passwd_file");
      print OUT_FILE "delimiter lessprobability;\n";
      print OUT_FILE "let new_pwd=$passwd";
      print OUT_FILE "lessprobability\n";
      print OUT_FILE "--delimiter ;\n";
      close(OUT_FILE);
    }
  }
  close(FILE);
EOF

source $passwd_file;

--echo # Restart the server against DDIR
--exec echo "restart:--datadir=$DDIR " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # connect as root
connect(root_con,localhost,root,$new_pwd,mysql);

--echo # reset the password
SET PASSWORD='';

--echo # Must have USAGE
--sorted_result
SHOW GRANTS FOR u1@localhost;
--echo # Must have a SELECT privilege
--sorted_result
SHOW GRANTS FOR u3@localhost;
--echo # Must have a password
SHOW CREATE USER u2@localhost;

--echo # shut server down
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--echo # Server is down

--echo # close the test connection
connection default;
disconnect root_con;

--echo # remove the password file
remove_file $PASSWD_FILE;

--echo # delete mysqld log
remove_file $MYSQLD_LOG;

--echo # delete bootstrap file
remove_file $BOOTSTRAP_SQL;

--echo # delete datadir
--perl
use File::Path 'rmtree';
$DDIR=$ENV{"DDIR"};
rmtree([ "$DDIR" ]);
EOF



--echo #
--echo # Cleanup
--echo #
--echo # Restarting the server
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

Man Man