LoginSignup
10
14

More than 3 years have passed since last update.

よく使うMySQLとRailsコマンド

Last updated at Posted at 2017-02-24

パスワードを指定してログインする方法

mysql -u root -pPASSWORD

本番環境コマンド

$ rake db:migrate RAILS_ENV=production

データベース確認

show databases;

テーブル確認

SHOW TABLES;

登録状況確認

select user,host from mysql.user;

本番環境

DISABLE_DATABASE_ENVIRONMENT_CHECK=1 rake db:migrate:reset RAILS_ENV=production

起動

mysql-ctl start

パスワード設定

SET PASSWORD = PASSWORD('some password')
SET PASSWORD FOR user = PASSWORD('some password')

ホスト変更

rename user test@localhost to sample@example.com

データベース削除

DROP DATABASE db_name;

テーブル作成

CREATE TABLE db_name.tbl_name
  (col_name1 data_type1, col_name2 data_type2, ...);
create table sampledb.personal(id int, name varchar(20));

Seed

rake db:seed RAILS_ENV=production
10
14
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
10
14