- Node.js 6.x Blueprints
- Fernando Monteiro
- 249字
- 2021-07-14 10:35:06
Creating the database on MySql
Before attempting to access the Mysql console make sure that it is running. To check that:
- Open terminal/shell and login your Mysql with the following command:
mysql -u root
- Remember, if you are using a different user or password, using the following command and replace
youruser
andyourpassword
for your own credentials:mysql -u youruser -p yourpassword
- Now let's create our database, type the following command:
CREATE DATABASE mvc_mysql_app;
- The result after the command will be the following line:
Query OK, 1 row affected (0,04 sec)
This confirms that the operation was successful, and we are ready to go forward.
Using db migrations to insert data on Mysql
Now is the time to do the migration of the schemes to the database. Again we use the sequelize-cli
for this migration. Before we proceed, we need to install a Mysql module manually.
- Open terminal/shell and type the following command:
npm install
Tip
Note that the
Sequelize
interface depends on the individual modules of each type of database used in the application, in our case we are useing Mysql - Open your terminal/shell and type the following command:
sequelize db:migrate
- This will be the result of the operation above, the output from your terminal:
Sequelize [Node: 6.3.0, CLI: 2.3.1, ORM: 3.19.3, mysql: ^2.10.2] Loaded configuration file "config/config.json". Using environment "development". Using gulpfile /usr/local/lib/node_modules/sequelize- cli/lib/gulpfile.js Starting 'db:migrate'... Finished 'db:migrate' after 438 ms == 20160319100145-create-user: migrating ======= == 20160319100145-create-user: migrated (0.339s) == 20160319101806-create-band: migrating ======= == 20160319101806-create-band: migrated (0.148s)
推薦閱讀
- The Supervised Learning Workshop
- MongoDB for Java Developers
- 匯編語言程序設(shè)計(第2版)
- SQL Server數(shù)據(jù)庫管理與開發(fā)兵書
- Creating Stunning Dashboards with QlikView
- 深度學(xué)習(xí):Java語言實現(xiàn)
- 搞定J2EE:Struts+Spring+Hibernate整合詳解與典型案例
- 深度學(xué)習(xí)原理與PyTorch實戰(zhàn)(第2版)
- Data Science Algorithms in a Week
- Arduino機器人系統(tǒng)設(shè)計及開發(fā)
- Visual Basic語言程序設(shè)計基礎(chǔ)(第3版)
- 原型設(shè)計:打造成功產(chǎn)品的實用方法及實踐
- Java多線程并發(fā)體系實戰(zhàn)(微課視頻版)
- Qt 5.12實戰(zhàn)
- 前端Serverless:面向全棧的無服務(wù)器架構(gòu)實戰(zhàn)