ERROR 1148 (42000): The used command is not allowed with this MySQL version

MySQLcsvファイルをインポートしようとすると以下のエラーが表示されました。

mysql> load data local infile '/tmp/(csvファイル名)' into table (テーブル名) fields terminated by ',';

ERROR 1148 (42000): The used command is not allowed with this MySQL version

mysqlコマンドの実行時、「--local_infile=1」パラメータを追加しlocalを有効にしてからloadを実行するとインポートすることができます。

$ mysql --local_infile=1 -u (ユーザ名) -p (データベース名)

こちらのURLを参考にさせていただきました。

MySQLデータのバックアップとリストア

ダンプデータを保存

  • データベース全体を保存。
$ mysqldump --single-transaction -u (ユーザ名) -p (データベース名) > out.dump
  • テーブルを指定して保存。
$ mysqldump --single-transaction -u (ユーザ名) -p -t  (データベース名) (テーブル名) > out.dump

備考
オプションを指定せず実行した場合、エラーが発生。

$ mysqldump -u (ユーザ名) -p (データベース名) > out.dump

エラー

mysqldump: Got error: 1044: Access denied for user (ユーザ名)@'localhost' to database (データベース名) when using LOCK TABLES

原因
テーブルロック権限(LOCK TABLES)がないため。
回避方法
オプション --single-transaction を使用。


ダンプデータをリストア

  • rootでの作業ができないため、out.dumpのデータをINSET...の部分だけに加工してリストアを実行。
$ mysql --default-character-set=utf8 -u (ユーザ名) -p (データベース名) < out.dump

備考
エラー
※ $ mysql -u (ユーザ名) -p (データベース名) < out.dump の実行ではエラーが発生。

ERROR 1044 (42000) at line 38: Access denied for user (ユーザ名)@'localhost' to database (データベース名)

※ --default-character-set=utf8を指定しないと文字化けする。

こちらのURLを参考にさせていただきました。

localeがUTF-8の環境でEUC-JPのデータベースを作成する

localeがUTF-8の環境でEUC_JPのデータベースを作成しようとしたら、以下のエラーが出力されました。

$ createdb -U (ユーザ) -E EUC_JP (データベース名)
createdb: database creation failed: ERROR:   encoding EUC_JP does not match locale jp_JP.UTF-8
DETAIL:   The chosen LC_CTYPE setting requires encoding UTF8

このような場合は、以下を実行します。

$ psql -U postgresql

postgres=# CREATE DATABASE (データベース名) WITH TEMPLATE=template0 ENCODING='EUC_JP' LC_COLLATE='C' LC_CTYPE='C';
CREATE DATABASE

これらのURLを参考にさせていただきました。

PostgreSQLからMySQLへのデータ移行

こちらのURLを参考にさせていただきました。

text型の列にインデックスを作成する

text型の列にインデックスを作成する場合、サイズを指定する必要があります。指定しないとエラーになります。
以下の内容では、nameカラムの最初の100文字を使用したインデックスが作成されます。

CREATE TABLE table01 (
    id int not null primary key auto_increment,
    name test
);

CTEATE INDEX index_name ON table01 (name(100));

こちらのURLを参考にさせていただきました。

子ウィンドウを表示後、子→親ウィンドウへデータの受け渡しを行う方法

  • index.py
<form action="XXX.py" method="post" name="inputForm01">
  <input type="text" class="detail" name="tableNum01" size="12" readonly>

  &nbsp;

  <a href="javascript:void(0)" onClick="window.open('attachedList.py', 'attachedList', 'menubar=no, height=400, width=300');"><button id="btnDetail" type="button" disabled>別表を開く</button></a>
</form>
  • attachedList.py
...
<script type="text/javascript" language="javascript">
  function ich(n) {
    window.opener.document.inputForm01.tableNum01.value=n;
    window.close();
  }
</script>

<table>
  <tr>
    <th>顧客コード</th>
    <th>顧客名称</th>
  </tr>
  
  <tr>
    <td><a href="javascript:ich('ABC商店')">0001</a></td>
    <td>ABC商店</td>
  </tr>

  <tr>
    <td><a href="javascript:ich('DEF商店')">0002</a></td>
    <td>DEF商店</td>
  </tr>
</table>

こちらのURLを参考にさせていただきました。