Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コマンド ラインで、MySQL SQL スクリプト ファイルから一部の (すべてではない) データ テーブルを復元しようとしています。ただし、単一のデータベース テーブルにはプレフィックスがあり、SQL ファイル テーブルにはありません。
コマンドライン内で復元時にプレフィックスを指定する方法はありますか?
mysql -uroot -p databasename < script_with_no_prefix.sql
コマンドを使用して、必要なテーブルを選択できますsed。たとえば、テーブルの接頭辞が「prefix_」の場合、次のように使用できます。
sed
$ sed -n -e '/^-- Table structure for table `prefix_/,/^UNLOCK TABLES/p' \ script_with_no_prefix.sql | mysql -uroot -p databasename