防忘録mysqlのコマンドライン
#{....}てのは名前の部分
■MySQLにrootユーザーでログインする
$mysql -u root
■パスワードを変更する:
>mysql set password for #{user}@#{host}= password('#{passwd}')
■データベースを作る
>mysql create database #{db};
■データベースを見る
>mysql show databases;
■使用するデータベースに移動する
>mysql use #{db};
■データベースにテーブルを作る
>mysql create table #{table}( id int not null auto_increment primary key, name varchar(20) not null);
■テーブルの構成を見る
>mysql show fields from #{table}
■データベース内にある全テーブルの名前を見る
>mysql show tables;
■テーブル内の全データを見る
>mysql select * from #{table};
■テーブルの中身を消去する
>mysql delete from #{table};
■ユーザーのアクセス権を変える
>mysql grant #{command} on #{db}.#{table} to #{user}@#{host};