By: Prem Tiwari | Last Updated:
Are you going to develop your web application in yii2 framwork, then this article will help you. The user table schema is not provided with yii2 starter kit by yii2 framework package. Below is proper user table schema.
How to create user table schema for yii2
1) Create database fro your yii2 application.
2) Open phpmyadmin in your browser like: http://localhost/phpmyadmin.
3) Select your database and click on SQL Tabs.
4) Copy below mysql query and paste into SQL editor.
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`auth_key` varchar(32) NOT NULL,
`password_hash` varchar(255) NOT NULL,
`password_reset_token` varchar(255) NOT NULL,
`email` varchar(100) NOT NULL,
`status` smallint(10) NOT NULL,
`role` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
PRIMARY KEY (`id`)
Insert below data in user table.
INSERT INTO `user` (`id`, `username`, `auth_key`, `password_hash`, `password_reset_token`, `email`, `status`, `role`, `created_at`, `updated_at`) VALUES
(1, 'admin', '', '$2y$13$uqe3LPW9ya3RZhynJpPN5um9fvdxUmoqjOqQBJDdIDXSKxRZB5bPu', '', '', 10, 0, 0, 0);
Now you can login in your application by using below username and password :
Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby. View all posts by Prem Tiwari