摘要
忘记密码对于这个不喜欢记密码又强迫症不喜欢用一个密码走天下的人来说和吃饭一样平凡的发生着
首先切换到git用户
su git -
注意下面的高亮行
git@57aab1253afd:~/gitlab$ bundle exec rails console production
Loading production environment (Rails 4.2.6)
irb(main):001:0> user = User.find_by(email: '[email protected]')
=> #
irb(main):002:0> user.password = 'LookBack'
=> "LookBack"
irb(main):003:0> user.password_confirmation = 'LookBack'
=> "LookBack"
irb(main):004:0> user.save
=> true
irb(main):005:0>
下面是重置docker环境下的gitlab的用户密码
[root@DS-VM-Node58 ~]# sed -n '/- DB_/p' /data/docker-compose.yml
- DB_ADAPTER=mysql2
- DB_HOST=127.0.0.1
- DB_PORT=****
- DB_USER=******
- DB_PASS=************
- DB_NAME=******
[root@DS-VM-Node58 ~]# docker exec -it gitlab_server bash
root@DS-VM-Node58:/home/git/gitlab# mysql -u****** -p************ ****** -h127.0.0.1 -e "select id,email,encrypted_password,username from users where username ='root';"
+----+-------------------+--------------------------------------------------------------+----------+
| id | email | encrypted_password | username |
+----+-------------------+--------------------------------------------------------------+----------+
| 1 | [email protected] | $2a$10$UPq7XEJVAxuX19q40H8CdeDAVriMVoKSlodqxhO6Vo4Wa7TH6oyKW | root |
+----+-------------------+--------------------------------------------------------------+----------+
root@DS-VM-Node58:/home/git/gitlab# bundle exec rails console production
Loading production environment (Rails 4.2.6)
irb(main):001:0> user = User.find_by(id: '1')
=> #
irb(main):002:0> user.password = 'LookBack.dwhd.org'
=> "LookBack.dwhd.org"
irb(main):003:0> user.password_confirmation = 'LookBack.dwhd.org'
=> "LookBack.dwhd.org"
irb(main):004:0> user.save!
=> true
irb(main):005:0> #按Ctrl+D键退出
root@DS-VM-Node58:/home/git/gitlab# mysql -u****** -p************ ****** -h127.0.0.1 -e "select id,email,encrypted_password,username from users where username ='root';"
+----+-------------------+--------------------------------------------------------------+----------+
| id | email | encrypted_password | username |
+----+-------------------+--------------------------------------------------------------+----------+
| 1 | [email protected] | $2a$10$dVahm7BERhs1eLD41h1kNe65OAM3YGLcQSUUnocWkvde6BDVjMGWe | root |
+----+-------------------+--------------------------------------------------------------+----------+
root@DS-VM-Node58:/home/git/gitlab# exit
exit
[root@DS-VM-Node58 ~]#