Local Installation of ERP NEXT

hi Gurus !
I 'm trying to install ERP locally , i have downloaded the virtual machine from erpnext.com/download imported in virtual box … now try to restore by .sql file taken from cloud . but getting following error …

erpnext@erpnext-vm:~/frappe-bench$ bench frappe --restore yh2hwev8eelhxa7o /home/test/database.sql -f
Traceback (most recent call last):
File “/home/erpnext/frappe-bench/env/bin/frappe”, line 5, in
from pkg_resources import load_entry_point
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py”, line 2701, in
parse_requirements(requires), Environment()
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py”, line 572, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: frappe==4.0.0

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 5.5.40-MariaDB-1~wheezy-log mariadb.org binary distribution

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| erpnext |
| mysql |
| performance_schema |
±-------------------+
4 rows in set (0.02 sec)

MariaDB [(none)]>

pkg_resources.DistributionNotFound: frappe==4.0.0 , I think this is the major problem … please help !

The command line has changed for v5,

See
bench restore --help

Thanks , I used

Although it didn’t give any error.

erpnext@erpnext-vm:~/frappe-bench$ bench restore --db-name yh2hwev8eelhxa7o /home/test/database.sql
erpnext@erpnext-vm:~/frappe-bench$ bench migrate
Migrating erpnext.erpnext-vm
Updating frappe : [========================================]
Updating erpnext : [========================================]
erpnext@erpnext-vm:~/frappe-bench$ pwd
/home/erpnext/frappe-bench
erpnext@erpnext-vm:~/frappe-bench$

But I don’t see any data new DB added
MariaDB [(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| erpnext |
| mysql |
| performance_schema |
±-------------------+
4 rows in set (0.02 sec)

and even when I see from front end application there is nothing in it. Please suggest.

Can any one help me ???

It’s done
and new db will not be added, old one was dropped and created again (erpnext)

Seems it is the case but the records are not found in the tables that’s strange. How can I insert the actual data.

MariaDB [erpnext]> select user,password from __Auth;
±------------------±------------------------------------------+
| user | password |
±------------------±------------------------------------------+
| Administrator | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
| irfan@xxxxxx | *3D39CFCA5E4CBDB378ED0ADD0381A355955F0F30 |
±------------------±------------------------------------------+
2 rows in set (0.00 sec)

But when I see the .sql file which I receieved table __Auth has much entries. How can I insert the actual data.

LOCK TABLES __Auth WRITE;
/*!40000 ALTER TABLE __Auth DISABLE KEYS */;
INSERT INTO __Auth VALUES (‘accounts@xxxx’,‘*9E14ED1D37983EFCD961808EA729F7D588A55D67’),(‘Administrator’,‘*07793E8CBEF0764C08D5FA0FC69CB54B7602F50D’),(‘ammad@axxxxxxx’,‘*FD147BE682B4614E32ADE7DF562CBD1B8040CB51’),(‘annie@xxxxxxx’,‘*9A97EFD6B224D3C2D62CC28125B96B04DC517738’),(‘arslan@xxxxxxx,’*FB1299B23A3DF1D
DA784AD30265409653398F260’),
S
NIP

/*!40000 ALTER TABLE __Auth ENABLE KEYS */;
UNLOCK TABLES;

Now I have done following … to import whole DB .

MariaDB [erpnext]> source /home/test/database.sql ;

which seem to have populated the tables… I 'm not sure what impact will it have on the front end application

For few minutes I could see the front end of the application showing new records and same like as on cloud
but now for web access
http://192.168.1.215:8080/desk#
I 'm getting internal server error. Help required …

Gurus !!

Waiting for suggestion . I 'm stuck .

Restore it using bench, this should work

bench update --pull
bench restore /path/to/sql
bench migrate

Thanks for the help … The first command worked and updates pulled. but rest of the two commands restore and migrate are not supported by bench. The difference I can see now after update the front end in web browser is giving 502 Bad gateway not "internal server error.
http://192.168.1.215:8080/desk#

erpnext@erpnext-vm:~/frappe-bench$ bench restore /home/test/database.sql
Usage: bench [OPTIONS] COMMAND [ARGS]…
Error: No such command “restore”.

erpnext@erpnext-vm:~/frappe-bench$ bench migrate
Usage: bench [OPTIONS] COMMAND [ARGS]…

Error: No such command “migrate”.

erpnext@erpnext-vm:~/frappe-bench$ bench --help
Usage: [OPTIONS] COMMAND [ARGS]…

Bench manager for Frappe

Options:
–help Show this message and exit.

Commands:
backup backup site
backup-all-sites backup all sites
config change bench configuration
get-app clone an app from the internet and set it up…
init Create a new bench
migrate-3to4 Migrate from ERPNext v3.x
new-app start a new app
new-site Create a new site in the bench
patch
prime-wheel-cache Update wheel cache
release Release app (internal to the Frappe team)
restart Restart supervisor processes
retry-upgrade
set-default-site Set default site for bench
set-mariadb-host Set MariaDB host for bench
set-nginx-port Set nginx port for site
set-ssl-certificate Set ssl certificate path for site
set-ssl-key Set ssl certificate private key path for site
set-url-root Set url root for site
setup Setup bench
shell
start Start Frappe development processes
switch-to-develop Switch frappe and erpnext to develop branch
switch-to-master Switch frappe and erpnext to master branch
switch-to-v4 Switch frappe and erpnext to v4 branch
update Update bench

erpnext@erpnext-vm:

Switch to version 5 first

bench switch-to-master
bench restore /path/to/sql
bench migrate

Still the same !!

erpnext@erpnext-vm:~$ bench switch-to-master

Switched to master
Please run bench update --patch to be safe from any differences in database schema
erpnext@erpnext-vm:~$ bench restore /home/test/database.sql
Usage: bench [OPTIONS] COMMAND [ARGS]…

Error: No such command “restore”.
erpnext@erpnext-vm:~$ bench restore /home/test/database.sql
Usage: bench [OPTIONS] COMMAND [ARGS]…

Error: No such command “restore”.
erpnext@erpnext-vm:~$ bench migrate
Usage: bench [OPTIONS] COMMAND [ARGS]…

Error: No such command “migrate”.
erpnext@erpnext-vm:~$

waiting for Help !!!

please let me know what to do next

waiting for next step guidance

I 'm stuck , please help for further steps !!

@shah Below is my 2 cents from what I have picked up along the way. No expert this worked for me.

Make sure that your existing cloud version is running the latest version of Frappe and ERPNext.
V5 has been updated to use MariaDB v10.x instead of MariaDB v5.5
Download a fresh new V5 VM and mount.
Run bench update until local VM is running the latest V5
Log into local ERPNext instance and use the setup wizard to create a (nearly) empty fresh V5 install.
SSH into the local MariaDB using a MySQL client and make a duplicate of your newly created ERPNext DB as a backup. So something like 1bd3e0294d_copy
Delete all tables within your local ERPNext DB but don’t delete the DB.
Import your existing .sql file into your local DB
Copy all of your exsisting image/pdf files etc from your cloud hosted instance: erpnext/sites/mysitename/public/files/
into your local VM instance directory:
erpnext/sites/mysitename/public/files/
When you login via web browser to your local ERPNext instance you should now see your previous ERPNext instance up and running. Your username and password will be the same as your old ERPNext instance.

This can be done more eloquently via bench commands but the guide above is pretty bullet proof.

Hope this helps

Thanks for such detailed step , sorry for the delayed response . I was away . seems a sturdy way :slight_smile: but let me try it.

On the latest vm (v5)

bench switch-to-master
bench restore /path/to/sql
bench migrate

Should work