'failed to open file in mysql database

i downloaded employees database from github that recommend mysql in its website but it has error in importing . how can i fix it? i dont think it is corrupt database.the error is

ERROR:
Failed to open file 'load_salaries1.dump', error: 2
ERROR:
Failed to open file 'load_salaries2.dump', error: 2
ERROR:
Failed to open file 'load_salaries3.dump', error: 2
ERROR:
Failed to open file 'show_elapsed.sql', error: 2

and my refrence https://dev.mysql.com/doc/employee/en/employees-installation.html and also it is added to my databases but with these errors



Solution 1:[1]

Error 2 in MySQL means "File not found." Make sure that you are in the right directory and you put quotation marks ("") around directory names that has a space.

Solution 2:[2]

The error message indicates that "File not Found". Double check your filename & file directory and then try again.

Solution 3:[3]

I used the following steps to import an sql file to my mysql application in ubuntu

1 - Download the .sql file and remember it's location.

2 - Open your mysql from command prompt or terminal.

3 - Create a database with the same name as that of the database present in the .sql file (create database your_database_name)

4 - Now exit out from the mysql command line client

5 - Now try and execute this command =>

mysql -u your_username -p your_database_name < your_sql_file_with_complete_location

example - mysql -u root -p trial < /home/abc/Desktop/trial.sql

here my .sql file is named trial and is present in the desktop, the database is also name trial

6 - You should now have your sql file imported to the corresponding mysql database.

Solution 4:[4]

I faced a similar problem and here is the solution.

Root Cause

The path for the dump files in the employees.sql script is not absolute or relative.

If you open the employees.sql script with an IDE (say, Visual Studio Code), you would find the below sql commands at the end of it.

SELECT 'LOADING salaries' as 'INFO';

source load_salaries1.dump ;

source load_salaries2.dump ;

source load_salaries3.dump ;

source show_elapsed.sql ;

Solution

Simply add the absolute path of the files and rerun the script file. Like below:

SELECT 'LOADING salaries' as 'INFO';

source C:/Users/abc/Downloads/test_db-master/load_salaries1.dump ;

source C:/Users/abc/Downloads/test_db-master/load_salaries2.dump ;

source C:/Users/abc/Downloads/test_db-master/load_salaries3.dump ;

source C:/Users/abc/Downloads/test_db-master/show_elapsed.sql ;

Note - You may have to do it for other such dump files as well in the employees.sql script

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jonathan
Solution 2 Aminul Islam
Solution 3 alex
Solution 4 M M