Advertisement
Advait08

hashcase database setup on linux

Jul 8th, 2024 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.01 KB | None | 0 0
  1. HASHCASE DATABASE SETUP FOR LINUX
  2.  
  3. 1. Install mysql-server
  4. > sudo apt install mysql-server
  5. > mysql --version
  6.  
  7. 2. Install mysql workbench
  8. VIA .deb
  9.  
  10. - Install all packages from https://dev.mysql.com/downloads/workbench/
  11. > sudo dpkg -i path_to_deb_file
  12.  
  13.  
  14. VIA SNAP
  15. > sudo apt install snapd
  16. > sudo snap insall mysql-workbench
  17.  
  18. 3. Configure mysql
  19. >sudo systemctl start mysql.service
  20. >sudo mysql_secure_installation
  21.  
  22. ```bash
  23. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
  24. Success.
  25. Normally, root should only be allowed to connect from
  26. 'localhost'. This ensures that someone cannot guess at
  27. the root password from the network.
  28.  
  29. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
  30.  
  31.  ... skipping.
  32. By default, MySQL comes with a database named 'test' that
  33. anyone can access. This is also intended only for testing,
  34. and should be removed before moving into a production
  35. environment.
  36.  
  37.  
  38. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
  39.  
  40.  ... skipping.
  41. Reloading the privilege tables will ensure that all changes
  42. made so far will take effect immediately.
  43.  
  44. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
  45. Success.
  46.  
  47. All done!
  48. ```
  49.  
  50. 4. Create Databases
  51. > sudo mysql -u root -p
  52. ```sql
  53. mysql> create database hashcase_db_dev;
  54. mysql> create database hashcase_db_test;
  55. ```
  56.  
  57. 5. Set password (for user=root  password=password) and configure mysql without sudo
  58. > sudo mysql -u root -p
  59.  
  60. ```sql
  61. mysql> show databases;
  62. mysql> use mysql
  63. mysql> select user, host, plugin from mysql.user;
  64. mysql> update user set plugin="mysql_native_password" where User="root";
  65. mysql> flush privileges;
  66. mysql> exit;
  67. ```
  68.  
  69. > mysql -u root
  70.  
  71. ```sql
  72. mysql> SET GLOBAL validate_password.policy=LOW;
  73. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
  74. mysql> exit
  75. ```
  76.  
  77. > sudo service mysql restart
  78.  
  79. 6. Workbench setup
  80.  - create a new connection with name hashcase_db_dev
  81.  - port is 3306 and hostname is localhost or 127.0.0.1
  82.  - username is root
  83.  - password is password
  84.  - run the mysql server
  85.  - make a connection with from the workbench
  86.  
  87.  7. Dumping into the database
  88.  
  89.  - Obtain the file hashcase_db.sql
  90.  > sudo mysql -u root -p hashcase_db_dev < hashcase_db.sql
  91.  > sudo mysql -u root -p hashcase_db_test < hashcase_db.sql
  92.  
  93. Final Notes:
  94. - If you get following error while running database migrations, execute the following code depending on error
  95.  
  96.     1. ERROR: Duplicate column name 'loyalty'
  97.       ```sql
  98.       mysql> insert into SequelizeMeta (name) values ("20240518160400-add-loyalty-to-user.js");
  99.       ```
  100.      
  101.      2. ERROR: Duplicate key name 'unique_code'
  102.         ```sql
  103.         mysql> insert into SequelizeMeta (name) values ("20240518160502-create-loyalty-table.js");
  104.         ```
  105.    
  106.     3. ERROR: Duplicate column name 'fuel_wallet_address'
  107.         ```sql
  108.         mysql> insert into SequelizeMeta (name) values ("20240604205346-add-fuel-wallet-address-to-users.js");
  109.         ```
  110.  
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement