一、使用mysql_config_editor。
1、将密码放入受保护的文件:
mysql_config_editor set --login-path=mylogin --host=localhost --user=root --socket=/tmp/mylogin.sock --password
回车输入密码。
2、打印一下生成文件的内容:mysql_config_editor print --all
3、使用加密文件登录:mysql --login-path=mylogin
二、PHP执行shell命令进行大数据量的SQL文件的导入。
exec("mysql --login-path=mylogin sampling < test.sql",$result,$status);//执行shell命令