0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

mysql メモ

Last updated at Posted at 2024-02-19
◆◆◆ mydqldump

1 mysql をシステムpathに追加する
2 cmd立ち上がる

★tdb全部テーブルをエクスポート
mysqldump -uroot -ptest tdb > e:\db\tbl-and-data.sql
mysqldump --user=root --password=test tdb  > e:\db\tbl-and-data.sql
注:ログインIDはroot  パスワードはtest  上記でわざとパスワード入力不要、便利です。
mysqldump -u root -p tdb  > e:\db\tbl-and-data.sql

〇特定なテーブルの場合
mysqldump -uroot -ptest tdb testtbl > e:\db\testtbl.sql
テーブル名はtesttbl

★test_db全部テーブルをインポート   注意:mysqldump ×  mysql 〇
mysql -uroot -ptest  --default-character-set=binary tdb < e:\db\tbl-and-data.sql
又は
mysql --user=root --password=test --default-character-set=binary tdb  <  e:\db\tbl-and-data.sql

〇特定なテーブルの場合
コマンドは上記のままです、データファイルの特定なテーブルのデータのみです。

厳重注意  日本語インポートエラーないように下記は必須です
--default-character-set=binary

◆◆◆ 外部キーテーブル作成
CREATE TABLE parent (
    id INT NOT NULL,
    PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE child (
    id INT,
    parent_id INT,
	PRIMARY KEY (id),
    INDEX par_ind (parent_id),
    FOREIGN KEY (parent_id)
        REFERENCES parent(id)
        ON DELETE CASCADE
) 

◆◆◆  Workbenchを日本語化
MySQL Workbenchを日本語化する(2024.3.22月時点)
MySQL Workbench Version8.0

https://ja.osdn.net/projects/oss-ja-jpn/releases/p10742
上記からダウンロード 非常に時間かかる。2時間???
連続解凍する
mysql-workbench-gpl_5.2.34_ja6.tar.gz
↓
mysql-workbench-gpl_5.2.34_ja6.gz
↓
mysql-workbench-gpl_5.2.34-6_i386.deb
↓
data.tar.gz
main_menu.xmlファイルはここ↓
usr/local/share/mysql-workbench/data/main_menu.xml
下記に上書き、再起動。
Application/MySQLWorkbench/Contents/Resources/data/main_menu.xml

★日本語文字化け防止設定
メインメニュー>MySQL Workbench>Preferences>Modeling>Appearance>Fonts
にアクセスし、「Configure Fonts For」にJapaneseを選択する。

ER図自動生成可能です。ただし、テーブル定義に必ず外部キー定義ある、ないとできない。
DB接続から作成する。sql文から作成できない、DB、テーブル選択できないから。

★7zip 日本語化にする
日本語化する方法は
左のstartメニューにある7-Zip File Managerに
ツール>オプション>言語
言語を日本語を選択する
インストール完了後PC再起動だけで右メニューも日本語になる


0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?