所以我对数据库很陌生,但我做了一些研究,我认为我已经弄清楚了我需要的一切,但是当我尝试运行我的脚本时遇到了错误。
这是我的脚本
mysql -h portal-rds -u $user --password=$mysqlpw <<QUERY_INPUT
CREATE DATABASE IF NOT EXISTS $DATABASE
use $DATABASE
CREATE TABLE IF NOT EXISTS backUpFiles (fileName VARCHAR(20), archiveId VARCHAR(500), checkSum VARCHAR(100), glacierVault VARCHAR(100), timeStamp date);
INSERT INTO backUpFiles
VALUES ('$archive_file_name', '$archiveID', '$CURRENTVAULT', '$checkSum', CURDATE());
QUERY_INPUT
我收到的错误是
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'use glacier
CREATE TABLE IF NOT EXISTS backUpFiles (fileName VARCHAR(20), archiveId VARCHAR(500), checkSum VARCHAR(100), glacierVault VARCHAR(100), timeStamp date);
Query OK, 0 rows affected, 1 warning (0.00 sec)
然后我决定手动登录mysql并运行这个命令,除了这个不应该破坏任何东西的警告之外,它们工作得很好(我相信)
mysql> show warnings;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1050 | Table 'backupfiles' already exists |
+-------+------+------------------------------------+
1 row in set (0.28 sec)