markdown 创建MSQL DB

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 创建MSQL DB相关的知识,希望对你有一定的参考价值。

## Creating a Database
* Using mysql, here are 4 commands when working with databases:
    * `SHOW DATABASES;`
    * `CREATE DATABASE db_name;`
    * `USE db_name;`
    * `DROP DATABASE db_name;`
    * **DON'T FORGET THE `;`!**
* Start up mysql server: `mysql.server start`
* then run `mysql -u root -p`, enter password
* `CREATE DATABASE name_development`
* Then `USE name_development` to run commands against that db
* Bad to use `root` user in mysql, create a new user for your app!
    * This command will create and grant the user all rights to the DB, after the `USE` db command
    
    ```
    GRANT ALL PRIVILIGES ON db_name.*
    TO 'username'@'localhost'
    IDENTIFIED BY 'password';
    
    SHOW GRANTS FOR 'username'@'localhost';
    ```
    
    * Now you can exit, and sign in as the new user and log in to a specific db:
    `mysql -u simple_cms -p simple_cms_development`
    * `SHOW TABLES;`
    * `SHOW FIELDS FROM USERS;`
    * `SELECT * FROM table_name;` is used to show what data is contained in the table.
* When you execute `SHOW TABLES`, you will notice a table called `schema migrations`. It contains
all the migration files from the `db/migrate` folder.
* Now that you have created a database, you have to tell rails to use it!
* In `config/database.yml`:

```yml
development:
  adapter: mysql2
  encoding: utf8
  database: simple_cms_development
  pool: 5
  username: simple_cms
  password: secretpassword
  socket: /tmp/mysql.sock
```

* Migrate the database schema into our app: `rake db:schema:dump`, empty schema, connection
successful!
* **YAML = YAML AIN'T MARKUP LANGUAGE**

以上是关于markdown 创建MSQL DB的主要内容,如果未能解决你的问题,请参考以下文章

MSQL 使用shell创建表格

msql 2000 使用DBCC CHECK DB 得出错误,槽引用错误

msql_DDL_创建table

根据查询的总结果检测页数的问题

Msql第三天,视图

msql数据迁移