What is so creative?

MySQL data import - CUI

サーバ移転時など、データ移行を行う必要がある。データ量が多すぎてphpMyAdminがタイムアウトになり、ブラウザからインポートできない場合がある。

そういった場合、コマンドラインからインポートすることで実現する。

 

①ログイン
[Linux]
 # mysql -u root -p
Enter password:
 
[Mac]
# /Applications/MAMP/Library/bin/mysql -u root -p
Enter password:
 
②データベース作成
mysql> create database {database_name};
 
③DB指定
mysql> use dbname
Database changed
 
④データファイルを指定してインポート
mysql> source /Users/{myname}/Downloads/data.sql
 
ちなみに
⑤ユーザ作成
mysql> grant all privileges on {database_name}.* to {user_name}@localhost identified by '{password}';

Comments

1 comments posted

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The information is very interesting.

Submitted by Anonymous user on 2012, January 14 - 08:48.

The information is very interesting. I like the post.  Thank you, this advice will come in handy. It made me understand something, and it is that I never knew before.
male waxing London

Post new comment

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.