Linux failed to open file error 2

When I tried to source for a particular .sql file, namely 'metropolises.sql' that I created and saved previously from a database, the following error is displayed: Failed to open file 'metropoli...

When I tried to source for a particular .sql file, namely 'metropolises.sql' that I created and saved previously from a database, the following error is displayed:

Failed to open file ‘metropolises.sql’, error: 2

Any idea what went wrong?

asked Feb 4, 2013 at 9:46

Clueless Gorilla's user avatar

Clueless GorillaClueless Gorilla

1,1692 gold badges10 silver badges15 bronze badges

2

Assuming you mean that you are trying to use the source command in order to execute SQL statements from a text file, the error number given appears to be passed through from the POSIX layer.

Therefore, using this resource, we can deduce that the error value of 2 means «no such file or directory».

In short, you got the path wrong.

Try providing an absolute path, as it’s not clear what the current working directory will be in the context of your MySQL server. You may be assuming that it’s the working directory of your shell, but it’s not obvious that we should expect this to be true.

answered Feb 4, 2013 at 9:59

Lightness Races in Orbit's user avatar

6

Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.

Example:

with backslashes : source C:folder1metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql

Alan's user avatar

Alan

1,7892 gold badges14 silver badges29 bronze badges

answered Jun 6, 2013 at 7:19

chad's user avatar

chadchad

1,2173 gold badges12 silver badges15 bronze badges

2

IF YOU ARE USING MYSQL INSIDE DOCKER

Note that if you are running MySQL inside docker then you must first copy the dump into your MySQL docker environment. To do that follow the steps below

  1. First, check and copy the container ID for your MySQL docker by:

    sudo docker ps

  2. Copy the SQL dump file into your container using:

    sudo docker cp /path/to/sql/file.sql MysqlDockerID:/

    This will copy the dump file into the docker root folder if you want to copy the file inside any other directory/path inside docker replace the ‘/’ after ‘MysqlDockerID:’ with the path you want appropriate one.

  3. Now to interact with MySQL inside a running container run the following command:

    sudo docker exec -it MysqlDockerID bin/bash

  4. Now connect to the MySQL using the terminal by:

    mysql -u yourUserName -p

    This will now ask you for the password. Enter the correct password to proceed.

  5. List the databases available by:

    show Databases;

    This will list out the available databases

  6. Assuming your database name where you want to import dump to is ‘MyDatabase’. Switch to that using:

    use MyDatabase

  7. Now you can import the file by typing:

    source file.sql

    Remember the above command works if you have copied your file into your root folder (using step 2). If you have copied it to any other path make sure you use that same path instead

answered Jun 19, 2020 at 7:20

Hadi Mir's user avatar

Hadi MirHadi Mir

4,2112 gold badges27 silver badges30 bronze badges

4

Related issue I had getting error 2 running source command: filename must not be in quotes even if it contains spaces in name or path to file.

answered Feb 2, 2014 at 8:40

user1906580's user avatar

user1906580user1906580

2392 silver badges4 bronze badges

1

It’s probably the file path to your file. If you don’t know the exact location of the file you want to use, try to find your file in Finder, then drag the file into Terminal window

mysql> SOURCE dragfilePathHere 

answered Apr 13, 2017 at 5:33

rocketTheCat's user avatar

1

I first reach to the file

c:windows>cd c:akuraDb Scripts

c:akuraDb Scripts>mysql -u root -p root

mysql>. EXECUTER_NEW_USER.sql

here EXECUTER_NEW_USER.sql my file name

Robert's user avatar

Robert

5,26743 gold badges65 silver badges115 bronze badges

answered Feb 4, 2014 at 10:48

user3030395's user avatar

I’ve had the same error on Windows.
I solved it with (after on cmd: mysql -u root):

mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;

Be sure you type the right file path

Ante's user avatar

Ante

5,3106 gold badges23 silver badges46 bronze badges

answered Jun 12, 2014 at 16:47

Alex_Aleluia's user avatar

On my windows 8.1, and mysql 5.7.9 MySQL Community Server (GPL),
I had to remove the ; after the file path.

This failed: source E:/jokoni/db/Banking/createTables.sql;

This Worked: source E:/jokoni/db/Banking/createTables.sql
(without termination, and forward slashes instead of windows’ backslashes in path)

answered Nov 25, 2015 at 5:22

LivePwndz's user avatar

LivePwndzLivePwndz

5901 gold badge7 silver badges14 bronze badges

0

If you are using vagrant ensure that the file is on the server and then use the path to the file. e.g if the file is stored in the public folder you will have

sql> source /var/www/public/xxx.sql

Where xxx is the name of the file

answered Aug 5, 2017 at 21:42

Ibrahim Isa's user avatar

Ibrahim IsaIbrahim Isa

5093 silver badges4 bronze badges

I got this error in mysql command line using this query:

source `db.sql`;

I changed the above to the following to make it work:

source db.sql;

answered Jun 29, 2015 at 8:58

Lpgfmk's user avatar

LpgfmkLpgfmk

3711 gold badge4 silver badges17 bronze badges

On my Mac, this is the only solution worked for me.

https://stackoverflow.com/a/45530305/5414448


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.

answered Jan 14, 2019 at 3:57

Andrew Rhyne's user avatar

I was having this issue and it turns out if you are using wamp server to run mysql, you have to use the file path within the wamp64 folder. So when the absolute path is: C:/wamp64/www/foldername/filename.sql
The path you have to use is:
www/foldername/filename.sql

answered Jul 22, 2020 at 17:14

craft9861's user avatar

craft9861craft9861

2042 silver badges8 bronze badges

May be the file name or path you are used may be incorrect

In my system i created file abcd.sql at c:

and used command mysql> source c:abcd.sql Then i got result

answered Feb 4, 2013 at 10:00

Fathah Rehman P's user avatar

Fathah Rehman PFathah Rehman P

8,2514 gold badges40 silver badges42 bronze badges

2

If you’re on Debian 8 (Jessie) Linux, try to cd into the directory of the 'metropolises.sql'. Run mysql and execute SOURCE ./metropolises.sql;

Basically, try the relative path. I tried this and it works.

answered Mar 31, 2016 at 23:10

T. Webster's user avatar

T. WebsterT. Webster

9,4556 gold badges66 silver badges94 bronze badges

If you are running dockerized MySQL container such as ones from this official Docker Image registry: https://hub.docker.com/_/mysql/ You may encounter this issue as well.

answered May 11, 2016 at 15:33

Devy's user avatar

DevyDevy

9,5017 gold badges60 silver badges57 bronze badges

For me it was because the file was located on a shared drive and it could not access, for some reason, to that path.
I cut the file and put it on my local drive in a path without spaces and it got resolved.

answered Dec 7, 2017 at 20:48

Camilo's user avatar

CamiloCamilo

4195 silver badges12 bronze badges

I got the same error when i used the command source and gave the sql file path by drag n dropping it.

Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.

soln:

source /home/xyz/file .sql ;(path and a space before file extension)

answered Jan 24, 2018 at 6:41

maithri poojary's user avatar

For Mac users, you can give the path as,

source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;

*I have assumed that the file you need to source is in your desktop and the file name is metropolises.sql


If you type,

source metropolises.sql

then the file will be look in the default location,

/Users/YOUR_USER_NAME/metropolises.sql;

answered Nov 24, 2018 at 6:26

Nadun Kulatunge's user avatar

Nadun KulatungeNadun Kulatunge

1,4572 gold badges18 silver badges28 bronze badges

The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.

answered Jan 13, 2019 at 10:44

Ricardo Gonçalves's user avatar

I had a problem on my Mac because one of the folder (directory) names in the path had a space in the name. BTW, the space was escaped by a , but that was not understood by mySQL

answered Apr 18, 2019 at 20:05

Rob's user avatar

solution — 1) Make sure you’re in the root folder of your app. eg app/db/schema.sql.

solution — 2) open/reveal the folder on your window and drag&&drop in the command line next to keywork source (space) filesource. eg source User/myMAC/app/db/schema.sql

answered Sep 19, 2019 at 1:50

Anand Chaudhary's user avatar

I get into this problem in my Xubuntu desktop. I fixed it by renaming all my files and folders so there is no space in the file path.

answered Jan 23, 2020 at 9:41

princebillyGK's user avatar

Passing the full path does not error, but if the folders have MySQL spaces it does not recognize the .sql file.
I have MySQL 8.0.21 on OS UNIX.

answered Jul 20, 2020 at 10:04

Gazzella's user avatar

I’ve got the same error on Windows. I solved it running the code on MySQL command line

source c:UsersxxDownloadsdata_file.sql

answered Mar 26, 2022 at 2:48

Tusar Ahmed's user avatar

1

Remove spaces in the folder names of the path, It worked for my mac path.

(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)

answered Mar 10, 2015 at 9:16

Loganathan's user avatar

LoganathanLoganathan

1,6371 gold badge13 silver badges17 bronze badges

0

I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.

C:UsersSubhenduD>cd ../
C:Users>cd ../
C:>cd xamppmysqlbin

C:xamppmysqlbin>mysql -u -root

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.


mysql> use balticktravels;

mysql> source balticktravels.sql;

Petro's user avatar

Petro

3,3853 gold badges28 silver badges56 bronze badges

answered Sep 12, 2016 at 5:40

subhendu das's user avatar

When you try to run an SQL file using mysql command line program, you may encounter an error saying Failed to open file error 2.

The following example tries to run the source command and execute the query.sql file:

mysql> source query.sql
ERROR: 
Failed to open file 'query.sql', error: 2

The code error 2 means that MySQL can’t find the .sql file that you want to execute.

To solve this error, you need to provide the absolute path to your file location.

You can find the absolute path of your file by opening the terminal in the directory or folder where your SQL file is located and run the pwd command.

For example, here’s the absolute path to the directory where I save the query.sql file:

$ pwd
/Users/nsebhastian/Desktop/SQL-files

Now I just need to add the path to the file when I issue the source command:

mysql> source /Users/nsebhastian/Desktop/SQL-files/query.sql

Please note that you need to use forward slashes (/) to separate your path sections. Using back slashes () may cause the same error.

Here’s an example:

mysql> source UsersnsebhastianDesktopSQL-filesquery.sql
ERROR: 
Failed to open file 'UsersnsebhastianDesktopSQL-filesquery.sql', error: 2

Even though the path is correct, MySQL expects a Unix-style path with forward slashes.

You should now be able to execute the SQL file. There are some other causes for error 2 in MySQL, so let’s take a look at that next.

Error 2 because of < or > symbols

Another thing that could cause the error is that you’re adding the greater than > or less than < symbol in front of the file path as shown below:

mysql> source < /Users/nsebhastian/Desktop/SQL-files/query.sql
ERROR: 
Failed to open file '< /Users/nsebhastian/Desktop/SQL-files/query.sql', 
error: 2

The greater than or less than symbol is commonly used to dump MySQL data to an SQL file or execute a script from the terminal without connecting to MySQL server.

You need to remove the symbol to execute the source command without error.

Error 2 because of semicolon when using . command

The . command is an alias of the source command that you can use to run an SQL file.

I don’t know if it’s a MySQL bug, but when you run the . command with a semicolon ; at the end of the file path, you’ll get the error 2 response.

Take a look at the following example:

mysql> . /Users/nsebhastian/Desktop/SQL-files/query.sql;
ERROR: 
Failed to open file '/Users/nsebhastian/Desktop/SQL-files/query.sql;', 
error: 2

But the same error won’t happen when you use the source command:

mysql> source /Users/nsebhastian/Desktop/SQL-files/query.sql;
...
# result
...
7 rows in set (0.00 sec)

To solve this issue, you need to omit the semicolon when you’re using the . command.

And that’s how you fix the MySQL failed to open file error 2 issue.

Just keep in mind that the error is because MySQL can’t find the file you want to execute.

You probably need to check the path you passed into the source command and see if there’s any typo that causes the error.

When I tried to source for a particular .sql file, namely 'metropolises.sql' that I created and saved previously from a database, the following error is displayed:

Failed to open file ‘metropolises.sql’, error: 2

Any idea what went wrong?

asked Feb 4, 2013 at 9:46

Clueless Gorilla's user avatar

Clueless GorillaClueless Gorilla

1,1692 gold badges10 silver badges15 bronze badges

2

Assuming you mean that you are trying to use the source command in order to execute SQL statements from a text file, the error number given appears to be passed through from the POSIX layer.

Therefore, using this resource, we can deduce that the error value of 2 means «no such file or directory».

In short, you got the path wrong.

Try providing an absolute path, as it’s not clear what the current working directory will be in the context of your MySQL server. You may be assuming that it’s the working directory of your shell, but it’s not obvious that we should expect this to be true.

answered Feb 4, 2013 at 9:59

Lightness Races in Orbit's user avatar

6

Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.

Example:

with backslashes : source C:folder1metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql

Alan's user avatar

Alan

1,7892 gold badges14 silver badges29 bronze badges

answered Jun 6, 2013 at 7:19

chad's user avatar

chadchad

1,2173 gold badges12 silver badges15 bronze badges

2

IF YOU ARE USING MYSQL INSIDE DOCKER

Note that if you are running MySQL inside docker then you must first copy the dump into your MySQL docker environment. To do that follow the steps below

  1. First, check and copy the container ID for your MySQL docker by:

    sudo docker ps

  2. Copy the SQL dump file into your container using:

    sudo docker cp /path/to/sql/file.sql MysqlDockerID:/

    This will copy the dump file into the docker root folder if you want to copy the file inside any other directory/path inside docker replace the ‘/’ after ‘MysqlDockerID:’ with the path you want appropriate one.

  3. Now to interact with MySQL inside a running container run the following command:

    sudo docker exec -it MysqlDockerID bin/bash

  4. Now connect to the MySQL using the terminal by:

    mysql -u yourUserName -p

    This will now ask you for the password. Enter the correct password to proceed.

  5. List the databases available by:

    show Databases;

    This will list out the available databases

  6. Assuming your database name where you want to import dump to is ‘MyDatabase’. Switch to that using:

    use MyDatabase

  7. Now you can import the file by typing:

    source file.sql

    Remember the above command works if you have copied your file into your root folder (using step 2). If you have copied it to any other path make sure you use that same path instead

answered Jun 19, 2020 at 7:20

Hadi Mir's user avatar

Hadi MirHadi Mir

4,2112 gold badges27 silver badges30 bronze badges

4

Related issue I had getting error 2 running source command: filename must not be in quotes even if it contains spaces in name or path to file.

answered Feb 2, 2014 at 8:40

user1906580's user avatar

user1906580user1906580

2392 silver badges4 bronze badges

1

It’s probably the file path to your file. If you don’t know the exact location of the file you want to use, try to find your file in Finder, then drag the file into Terminal window

mysql> SOURCE dragfilePathHere 

answered Apr 13, 2017 at 5:33

rocketTheCat's user avatar

1

I first reach to the file

c:windows>cd c:akuraDb Scripts

c:akuraDb Scripts>mysql -u root -p root

mysql>. EXECUTER_NEW_USER.sql

here EXECUTER_NEW_USER.sql my file name

Robert's user avatar

Robert

5,26743 gold badges65 silver badges115 bronze badges

answered Feb 4, 2014 at 10:48

user3030395's user avatar

I’ve had the same error on Windows.
I solved it with (after on cmd: mysql -u root):

mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;

Be sure you type the right file path

Ante's user avatar

Ante

5,3106 gold badges23 silver badges46 bronze badges

answered Jun 12, 2014 at 16:47

Alex_Aleluia's user avatar

On my windows 8.1, and mysql 5.7.9 MySQL Community Server (GPL),
I had to remove the ; after the file path.

This failed: source E:/jokoni/db/Banking/createTables.sql;

This Worked: source E:/jokoni/db/Banking/createTables.sql
(without termination, and forward slashes instead of windows’ backslashes in path)

answered Nov 25, 2015 at 5:22

LivePwndz's user avatar

LivePwndzLivePwndz

5901 gold badge7 silver badges14 bronze badges

0

If you are using vagrant ensure that the file is on the server and then use the path to the file. e.g if the file is stored in the public folder you will have

sql> source /var/www/public/xxx.sql

Where xxx is the name of the file

answered Aug 5, 2017 at 21:42

Ibrahim Isa's user avatar

Ibrahim IsaIbrahim Isa

5093 silver badges4 bronze badges

I got this error in mysql command line using this query:

source `db.sql`;

I changed the above to the following to make it work:

source db.sql;

answered Jun 29, 2015 at 8:58

Lpgfmk's user avatar

LpgfmkLpgfmk

3711 gold badge4 silver badges17 bronze badges

On my Mac, this is the only solution worked for me.

https://stackoverflow.com/a/45530305/5414448


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.

answered Jan 14, 2019 at 3:57

Andrew Rhyne's user avatar

I was having this issue and it turns out if you are using wamp server to run mysql, you have to use the file path within the wamp64 folder. So when the absolute path is: C:/wamp64/www/foldername/filename.sql
The path you have to use is:
www/foldername/filename.sql

answered Jul 22, 2020 at 17:14

craft9861's user avatar

craft9861craft9861

2042 silver badges8 bronze badges

May be the file name or path you are used may be incorrect

In my system i created file abcd.sql at c:

and used command mysql> source c:abcd.sql Then i got result

answered Feb 4, 2013 at 10:00

Fathah Rehman P's user avatar

Fathah Rehman PFathah Rehman P

8,2514 gold badges40 silver badges42 bronze badges

2

If you’re on Debian 8 (Jessie) Linux, try to cd into the directory of the 'metropolises.sql'. Run mysql and execute SOURCE ./metropolises.sql;

Basically, try the relative path. I tried this and it works.

answered Mar 31, 2016 at 23:10

T. Webster's user avatar

T. WebsterT. Webster

9,4556 gold badges66 silver badges94 bronze badges

If you are running dockerized MySQL container such as ones from this official Docker Image registry: https://hub.docker.com/_/mysql/ You may encounter this issue as well.

answered May 11, 2016 at 15:33

Devy's user avatar

DevyDevy

9,5017 gold badges60 silver badges57 bronze badges

For me it was because the file was located on a shared drive and it could not access, for some reason, to that path.
I cut the file and put it on my local drive in a path without spaces and it got resolved.

answered Dec 7, 2017 at 20:48

Camilo's user avatar

CamiloCamilo

4195 silver badges12 bronze badges

I got the same error when i used the command source and gave the sql file path by drag n dropping it.

Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.

soln:

source /home/xyz/file .sql ;(path and a space before file extension)

answered Jan 24, 2018 at 6:41

maithri poojary's user avatar

For Mac users, you can give the path as,

source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;

*I have assumed that the file you need to source is in your desktop and the file name is metropolises.sql


If you type,

source metropolises.sql

then the file will be look in the default location,

/Users/YOUR_USER_NAME/metropolises.sql;

answered Nov 24, 2018 at 6:26

Nadun Kulatunge's user avatar

Nadun KulatungeNadun Kulatunge

1,4572 gold badges18 silver badges28 bronze badges

The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.

answered Jan 13, 2019 at 10:44

Ricardo Gonçalves's user avatar

I had a problem on my Mac because one of the folder (directory) names in the path had a space in the name. BTW, the space was escaped by a , but that was not understood by mySQL

answered Apr 18, 2019 at 20:05

Rob's user avatar

solution — 1) Make sure you’re in the root folder of your app. eg app/db/schema.sql.

solution — 2) open/reveal the folder on your window and drag&&drop in the command line next to keywork source (space) filesource. eg source User/myMAC/app/db/schema.sql

answered Sep 19, 2019 at 1:50

Anand Chaudhary's user avatar

I get into this problem in my Xubuntu desktop. I fixed it by renaming all my files and folders so there is no space in the file path.

answered Jan 23, 2020 at 9:41

princebillyGK's user avatar

Passing the full path does not error, but if the folders have MySQL spaces it does not recognize the .sql file.
I have MySQL 8.0.21 on OS UNIX.

answered Jul 20, 2020 at 10:04

Gazzella's user avatar

I’ve got the same error on Windows. I solved it running the code on MySQL command line

source c:UsersxxDownloadsdata_file.sql

answered Mar 26, 2022 at 2:48

Tusar Ahmed's user avatar

1

Remove spaces in the folder names of the path, It worked for my mac path.

(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)

answered Mar 10, 2015 at 9:16

Loganathan's user avatar

LoganathanLoganathan

1,6371 gold badge13 silver badges17 bronze badges

0

I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.

C:UsersSubhenduD>cd ../
C:Users>cd ../
C:>cd xamppmysqlbin

C:xamppmysqlbin>mysql -u -root

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.


mysql> use balticktravels;

mysql> source balticktravels.sql;

Petro's user avatar

Petro

3,3853 gold badges28 silver badges56 bronze badges

answered Sep 12, 2016 at 5:40

subhendu das's user avatar

Содержание

  1. MySQL — How to solve ‘Failed to open file error 2’
  2. Error 2 because of symbols
  3. Error 2 because of semicolon when using . command
  4. Level up your programming skills
  5. About
  6. MySQL Failed to open file – error 2 and 22 on Windows
  7. Share this:
  8. 30 Comments
  9. Consent to the use of Personal Data and Cookies
  10. Solution to SOURCE Error 2 with MySQL
  11. Writing file paths
  12. RTFM.WIKI
  13. Инструменты пользователя
  14. Инструменты сайта
  15. Содержание
  16. MySQL — коллекция ошибок и фиксов
  17. Ошибки
  18. Foreign key / Внешние ключи / Ошибка #1217
  19. Run ‘systemctl daemon-reload’ to reload units
  20. Can’t init tc log
  21. MySQL “Got an error reading communication packet” errors
  22. #1524 — Plugin ‘unix_socket’ is not loaded
  23. Can’t create a new thread (errno 11)
  24. #1698 — Access denied for user ‘root’@’localhost’
  25. mysqldump: Couldn’t execute ‘show events’
  26. #1214 — The used table type doesn’t support FULLTEXT indexes
  27. Waiting for table metadata lock
  28. No directory, logging in with HOME=/
  29. Can’t create thread to kill server (errno= 11)
  30. Can’t create a new thread (errno 11)
  31. unknown variable ‘default-tmp-storage-engine=MyISAM’
  32. Host ‘a.b.c.d’ is blocked because of many connection errors; unblock with ‘myscladmin flush-hosts’
  33. Fatal error: Uncaught exception ‘Exception’ with message ‘Error: Can’t open file: ‘./ocr/oc_product.frm’ (errno: 24)
  34. InnoDB: mmap(137363456 bytes) failed; errno 12
  35. Правильный UTF-8
  36. #1146 — Table ‘data_dictionary.CHARACTER_SETS’ doesn’t exist
  37. /usr/sbin/mysqld: Error on realpath() on ‘/var/lib/mysql-files’ (Error 2)
  38. ‘ERROR 1214 (HY000) at line 784: The used table type doesn’t support FULLTEXT indexes ‘
  39. Got an error from unknown thread, /builddir/build/BUILD /storage/myisam/mi_write.c:226
  40. mysqldump: Got error: (Errcode: 24) when using LOCK TABLES
  41. Error Number: 1364
  42. #1030 — Got error -1 from storage engine
  43. error: ‘Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)’
  44. open-files-limit в MariaDB
  45. Unable to lock ./ibdata1, error: 11
  46. unknown option ‘—skip-locking’
  47. RTFM.WIKI
  48. Инструменты пользователя
  49. Инструменты сайта
  50. Содержание
  51. MySQL — коллекция ошибок и фиксов
  52. Ошибки
  53. Foreign key / Внешние ключи / Ошибка #1217
  54. Run ‘systemctl daemon-reload’ to reload units
  55. Can’t init tc log
  56. MySQL “Got an error reading communication packet” errors
  57. #1524 — Plugin ‘unix_socket’ is not loaded
  58. Can’t create a new thread (errno 11)
  59. #1698 — Access denied for user ‘root’@’localhost’
  60. mysqldump: Couldn’t execute ‘show events’
  61. #1214 — The used table type doesn’t support FULLTEXT indexes
  62. Waiting for table metadata lock
  63. No directory, logging in with HOME=/
  64. Can’t create thread to kill server (errno= 11)
  65. Can’t create a new thread (errno 11)
  66. unknown variable ‘default-tmp-storage-engine=MyISAM’
  67. Host ‘a.b.c.d’ is blocked because of many connection errors; unblock with ‘myscladmin flush-hosts’
  68. Fatal error: Uncaught exception ‘Exception’ with message ‘Error: Can’t open file: ‘./ocr/oc_product.frm’ (errno: 24)
  69. InnoDB: mmap(137363456 bytes) failed; errno 12
  70. Правильный UTF-8
  71. #1146 — Table ‘data_dictionary.CHARACTER_SETS’ doesn’t exist
  72. /usr/sbin/mysqld: Error on realpath() on ‘/var/lib/mysql-files’ (Error 2)
  73. ‘ERROR 1214 (HY000) at line 784: The used table type doesn’t support FULLTEXT indexes ‘
  74. Got an error from unknown thread, /builddir/build/BUILD /storage/myisam/mi_write.c:226
  75. mysqldump: Got error: (Errcode: 24) when using LOCK TABLES
  76. Error Number: 1364
  77. #1030 — Got error -1 from storage engine
  78. error: ‘Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)’
  79. open-files-limit в MariaDB
  80. Unable to lock ./ibdata1, error: 11
  81. unknown option ‘—skip-locking’

MySQL — How to solve ‘Failed to open file error 2’

Posted on Nov 03, 2021

Learn how to fix ‘Failed to open file error 2’ in MySQL

When you try to run an SQL file using mysql command line program, you may encounter an error saying Failed to open file error 2 .

The following example tries to run the source command and execute the query.sql file:

The code error 2 means that MySQL can’t find the .sql file that you want to execute.

To solve this error, you need to provide the absolute path to your file location.

You can find the absolute path of your file by opening the terminal in the directory or folder where your SQL file is located and run the pwd command.

For example, here’s the absolute path to the directory where I save the query.sql file:

Now I just need to add the path to the file when I issue the source command:

Please note that you need to use forward slashes ( / ) to separate your path sections. Using back slashes ( ) may cause the same error.

Here’s an example:

Even though the path is correct, MySQL expects a Unix-style path with forward slashes.

You should now be able to execute the SQL file. There are some other causes for error 2 in MySQL, so let’s take a look at that next.

Error 2 because of symbols

Another thing that could cause the error is that you’re adding the greater than > or less than symbol in front of the file path as shown below:

The greater than or less than symbol is commonly used to dump MySQL data to an SQL file or execute a script from the terminal without connecting to MySQL server.

You need to remove the symbol to execute the source command without error.

Error 2 because of semicolon when using . command

The . command is an alias of the source command that you can use to run an SQL file.

I don’t know if it’s a MySQL bug, but when you run the . command with a semicolon ; at the end of the file path, you’ll get the error 2 response.

Take a look at the following example:

But the same error won’t happen when you use the source command:

To solve this issue, you need to omit the semicolon when you’re using the . command.

And that’s how you fix the MySQL failed to open file error 2 issue.

Just keep in mind that the error is because MySQL can’t find the file you want to execute.

You probably need to check the path you passed into the source command and see if there’s any typo that causes the error.

Level up your programming skills

I’m sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I’ll send new stuff straight into your inbox!

About

Nathan Sebhastian is a software engineer with a passion for writing tech tutorials.
Learn JavaScript and other web development technology concepts through easy-to-understand explanations written in plain English.

Источник

MySQL Failed to open file – error 2 and 22 on Windows

I recently had to restore a MySQL backup. It had been a while since I used MySQL, having switched to Postgresql sometime back. First thing I noticed was the lack of a GUI admin tool that PG spoils you with. Making matters worse, the command line tool isn’t even added to your path; you can’t just run “ mysql ” like you can in a Unix shell, much less use the redirect shortcut. And I was getting errors.

Here’s what you need to do to restore a MySQL backup on Windows:

  1. Run the command line tool from the start menu
  2. Open your backup file in a text editor. Does it start with a command to create or “use” the database? If not
    1. Create it, if necessary
    2. Type “use database” filling in your DB name
  3. Type “source path-to-SQL-file“. BUT, you must follow these rules:
    1. Use the full source command, not the . shortcut
    2. Have no spaces in your path. I copied mine to a root of a drive. Note that spaces in the file name is OK, just not the path.
    3. Do not quote the file name, even if it has spaces. This gave error 22.
    4. Use forward slashes in the path, e.g., C:/path/to/filename.sql. Otherwise you’ll get error 2.
    5. Do not end with a semicolon.

Follow all those rules and it should work fine.

Thanks so much for this info. You where a savior to me this night. In my work for a project for this my site,Code Messiah, I run into an issue when I have to migrate some project in .net to MySQL. Thanks you for this guide. Its short but henvy

Thank you so much

Hi, just a heads up;
You can use backslashes but you’ll have to escape them (“\”); and you can use semicolons, it worked as well. However I wouldn’t have figured out that the problem was the spaces in the path, that’s the main issue! So thanks for the article!

Thank you very much, it works!

This was quite helpful. Thanks for the tips.

Источник

Consent to the use of Personal Data and Cookies

This website needs your consent to use cookies in order to customize ads and content.

If you give us your consent, data may be shared with Google.

Solution to SOURCE Error 2 with MySQL

The error happens when importing database backups using the SOURCE command, either because you got the path wrong, or because you used the command incorrectly.

Edited: 2021-01-26 15:34

This is just a quick reminder to those having problems backing up- and importing MySQL databases. Often when I try to import a database using the SOURCE command I will get a SOURCE error 2 message.

The error simply means that we have gotten the file path wrong. However, in my case, it was because I used a less than sign between the SOURCE and the file name.

The reason for my mistake is that I use a greater than sign when backing up a database using mysqldump, and sometimes I mess up because the same logic does not apply when importing. Hopefully I will remember it now.

Writing file paths

To understand how to write the file system paths, read this article: Absolute and Relative Paths

Basically, when making backups, you can either write an absolute path for the destination file, beginning with a forward slash «/», or you can use a relative path. Simply writing the file name of the destination file will write the file in the current directory.

You can use the CD command to navigate to the desired location, if you feel more comfortable doing that.

Источник

RTFM.WIKI

Ordnung muß sein. Ordnung über alles (18+)

Инструменты пользователя

Инструменты сайта

Содержание

MySQL — коллекция ошибок и фиксов

Ошибки

Foreign key / Внешние ключи / Ошибка #1217

Теория в другом месте. Только фикс.

Текст ошибки может быть разным

В mysql cli отключаем проверку внешних ключей, делаем нужный запрос, включаем обратно.

можно ещё проще сделать

Run ‘systemctl daemon-reload’ to reload units

Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.

Can’t init tc log

MySQL “Got an error reading communication packet” errors

#1524 — Plugin ‘unix_socket’ is not loaded

Can’t create a new thread (errno 11)

Ошибка Can’t create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS -dependent bug

Лимиты установленные для MySQL в файле /etc/security/limits.conf будут переопределены файлом /etc/security/limits.d/90-nproc.conf . Поэтому задавать лимиты нужно в 90-nproc.conf или создать отдельный файл 91-mysql.conf

#1698 — Access denied for user ‘root’@’localhost’

Не работает phpmyadmin под root’ом. Для MySQL 127.0.0.1 и localhost это разные хосты.

Добавляем отдельного пользователя для администрирования

что-то там с sudo и unix_socket, не разбирался пока, но вариант рабочий.

mysqldump: Couldn’t execute ‘show events’

Ошибка mysqldump: Couldn’t execute ‘show events’: Cannot proceed because system tables used by Event Scheduler were found damaged at server start после перехода на MariaDB с MySQL 56 на cPanel сервере

mysql_upgrade по рекомендациям тоже не работает с ошибкой mysqldump: Got error: 1102: Incorrect database name ‘#mysql50#.config’» when selecting the database

И мне помог не cPanel, а Plesk

В /var/lib/mysql/ был каталог с точкой в имени.

Чтобы его найти выполним команду

Решение

Удалить/перенести каталог в другой место, выполнить mysql_upgrade.

#1214 — The used table type doesn’t support FULLTEXT indexes

Индексы FULLTEXT поддерживаются в таблицах InnoDB только начиная с MYSQL 5.6, поэтому попробуйте обновить MYSQL и после этого изменить команду таблицы

Waiting for table metadata lock

No directory, logging in with HOME=/

Подобная ошибка была в Debian с репозиторием dotdeb.

Надо поправить /etc/passwd

Должно быть так

Can’t create thread to kill server (errno= 11)

Скорее всего на сервере недостаточно памяти для выбранных настроек в my.cnf .

Т.е. key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections в итоге получается больше чем RAM на сервере.

Решение — уменьшить max_connections и другие параметры исходя из доступных ресурсов.

Can’t create a new thread (errno 11)

Ошибка похожа на Can’t create thread to kill server и также связана с лимитами.

В данном случае нужно увеличить количество открытых файлов и количество процессов ( nofile и nproc ).

По-умолчанию open files равен 1024.

Проверим, чтобы удостовериться

Добавляем в файл /etc/security/limits.conf

Либо устанавливаем лимит только для mysql

Нашёл рекомендацию добавить лимиты в отдельный файл 99-mysql.conf в каталоге /etc/security/limits.d/

unknown variable ‘default-tmp-storage-engine=MyISAM’

Вот такая ошибка может возникнуть если бездумно копировать из разных блогов советы бывалых админов

default-tmp-storage-engine появился только в MySQL 5.6 и если использовать опцию в версии 5.5, то MySQL не запустится.

Host ‘a.b.c.d’ is blocked because of many connection errors; unblock with ‘myscladmin flush-hosts’

Ошибка возникает после 10 (по-умолчанию) неудачных соединений с базой.

Fatal error: Uncaught exception ‘Exception’ with message ‘Error: Can’t open file: ‘./ocr/oc_product.frm’ (errno: 24)

В логе mariadb.log нечто подобное

Решение — см. запись ниже open-files-limit в MariaDB

Текущее использование открытых файлов можно посмотреть так:

InnoDB: mmap(137363456 bytes) failed; errno 12

Решение — уменьшить innodb_buffer_pool_size или добавить RAM.

Правильный UTF-8

а потом трахбах и deprecated

#1146 — Table ‘data_dictionary.CHARACTER_SETS’ doesn’t exist

И опять убунта. Что за чудо система. Не даёт скучать. Сиди чини её нескончаемые баги. Впрочем ничего нового.

И всё начинает работать. До следующего адового бага. Продакшен реди итиху мать.

/usr/sbin/mysqld: Error on realpath() on ‘/var/lib/mysql-files’ (Error 2)

Баг после апгрейда встретился только в Ubuntu

ЕМНИП нужно просто создать каталог /var/lib/mysql-files

‘ERROR 1214 (HY000) at line 784: The used table type doesn’t support FULLTEXT indexes ‘

FULLTEXT INDEX раньше работал только с MyISAM. С версии 5.6 доступен в InnoDB.

Так что либо апгрейд либо ALTER TABLE `yourtable` ENGINE = MyISAM;

Got an error from unknown thread, /builddir/build/BUILD /storage/myisam/mi_write.c:226

Также в логах может быть что-то вроде Incorrect key file for table ‘xyz.MYI’; try to repair it

Казалось бы следует сделать mysqlrepair –auto-repair . Но обычно это не помогает.

Скорее всего нет инодов или кончилось место или недоступен tmpdir в mysql.

Проверяем df -i и df -h . Также проверяем значение tmpdir в my.cnf

mysqldump: Got error: (Errcode: 24) when using LOCK TABLES

Узнал о крутой утилите perror. По коду ошибки покажет, что не так.

Ну и по ошибке выше — попробуйте добавить опцию —single-transaction к mysqldump

Error Number: 1364

Через tcpdump выловил ошибку в php-fpm

Виной всему старый код и новый (5.7) MySQL.

Быстрый фикс — выключить так называемый strict mode

Для этого нужно добавить в my.cnf

Можно также вынести в отдельный файл /etc/mysql/conf.d/disable_strict_mode.cnf

Проверить sql_mode

#1030 — Got error -1 from storage engine

При попытке выполнить SQL запрос в phpmyadmin получаем ошибку #1030 — Got error -1 from storage engine

Вероятно включен innodb_force_recovery в файле my.cnf .

Проверяем логи. Если есть нечто подобное

то значит так оно и есть. Выключаем innodb_force_recovery и всё снова работает.

error: ‘Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)’

Смотрим пароль пользователя debian-sys-maint в файле /etc/mysql/debian.cnf

Выполняем 2 SQL запроса, чтобы вернуть гражданину debian-sys-maint его привилегии

Перезапускаем MySQL сервер

open-files-limit в MariaDB

Systemd самостоятельно контролирует, сколько файлов служба (в нашем случае mariadb-server) может открыть, независимо от того, что вы настроили в /etc/my.cnf или в /etc/security/limits.conf .

И вносим следующие правки

Данные новшества однако документированы. Так что надо просто внимательнее читать release notes и changelog.

Unable to lock ./ibdata1, error: 11

Решение в сети, которое якобы некоторым помогает

увы не помогает.

Бытует мнение, что виной всему Apparmor т.к. нигде кроме Ubuntu ошибка эта не встречалась

Можно попробовать добавить в /etc/apparmor.d/usr.sbin.mysqld

надо проверить

unknown option ‘—skip-locking’

Опцию –skip-locking убрали в MySQL 5.5.

Решение: заменить skip-locking на skip-external-locking

Источник

RTFM.WIKI

Ordnung muß sein. Ordnung über alles (18+)

Инструменты пользователя

Инструменты сайта

Содержание

MySQL — коллекция ошибок и фиксов

Ошибки

Foreign key / Внешние ключи / Ошибка #1217

Теория в другом месте. Только фикс.

Текст ошибки может быть разным

В mysql cli отключаем проверку внешних ключей, делаем нужный запрос, включаем обратно.

можно ещё проще сделать

Run ‘systemctl daemon-reload’ to reload units

Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.

Can’t init tc log

MySQL “Got an error reading communication packet” errors

#1524 — Plugin ‘unix_socket’ is not loaded

Can’t create a new thread (errno 11)

Ошибка Can’t create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS -dependent bug

Лимиты установленные для MySQL в файле /etc/security/limits.conf будут переопределены файлом /etc/security/limits.d/90-nproc.conf . Поэтому задавать лимиты нужно в 90-nproc.conf или создать отдельный файл 91-mysql.conf

#1698 — Access denied for user ‘root’@’localhost’

Не работает phpmyadmin под root’ом. Для MySQL 127.0.0.1 и localhost это разные хосты.

Добавляем отдельного пользователя для администрирования

что-то там с sudo и unix_socket, не разбирался пока, но вариант рабочий.

mysqldump: Couldn’t execute ‘show events’

Ошибка mysqldump: Couldn’t execute ‘show events’: Cannot proceed because system tables used by Event Scheduler were found damaged at server start после перехода на MariaDB с MySQL 56 на cPanel сервере

mysql_upgrade по рекомендациям тоже не работает с ошибкой mysqldump: Got error: 1102: Incorrect database name ‘#mysql50#.config’» when selecting the database

И мне помог не cPanel, а Plesk

В /var/lib/mysql/ был каталог с точкой в имени.

Чтобы его найти выполним команду

Решение

Удалить/перенести каталог в другой место, выполнить mysql_upgrade.

#1214 — The used table type doesn’t support FULLTEXT indexes

Индексы FULLTEXT поддерживаются в таблицах InnoDB только начиная с MYSQL 5.6, поэтому попробуйте обновить MYSQL и после этого изменить команду таблицы

Waiting for table metadata lock

No directory, logging in with HOME=/

Подобная ошибка была в Debian с репозиторием dotdeb.

Надо поправить /etc/passwd

Должно быть так

Can’t create thread to kill server (errno= 11)

Скорее всего на сервере недостаточно памяти для выбранных настроек в my.cnf .

Т.е. key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections в итоге получается больше чем RAM на сервере.

Решение — уменьшить max_connections и другие параметры исходя из доступных ресурсов.

Can’t create a new thread (errno 11)

Ошибка похожа на Can’t create thread to kill server и также связана с лимитами.

В данном случае нужно увеличить количество открытых файлов и количество процессов ( nofile и nproc ).

По-умолчанию open files равен 1024.

Проверим, чтобы удостовериться

Добавляем в файл /etc/security/limits.conf

Либо устанавливаем лимит только для mysql

Нашёл рекомендацию добавить лимиты в отдельный файл 99-mysql.conf в каталоге /etc/security/limits.d/

unknown variable ‘default-tmp-storage-engine=MyISAM’

Вот такая ошибка может возникнуть если бездумно копировать из разных блогов советы бывалых админов

default-tmp-storage-engine появился только в MySQL 5.6 и если использовать опцию в версии 5.5, то MySQL не запустится.

Host ‘a.b.c.d’ is blocked because of many connection errors; unblock with ‘myscladmin flush-hosts’

Ошибка возникает после 10 (по-умолчанию) неудачных соединений с базой.

Fatal error: Uncaught exception ‘Exception’ with message ‘Error: Can’t open file: ‘./ocr/oc_product.frm’ (errno: 24)

В логе mariadb.log нечто подобное

Решение — см. запись ниже open-files-limit в MariaDB

Текущее использование открытых файлов можно посмотреть так:

InnoDB: mmap(137363456 bytes) failed; errno 12

Решение — уменьшить innodb_buffer_pool_size или добавить RAM.

Правильный UTF-8

а потом трахбах и deprecated

#1146 — Table ‘data_dictionary.CHARACTER_SETS’ doesn’t exist

И опять убунта. Что за чудо система. Не даёт скучать. Сиди чини её нескончаемые баги. Впрочем ничего нового.

И всё начинает работать. До следующего адового бага. Продакшен реди итиху мать.

/usr/sbin/mysqld: Error on realpath() on ‘/var/lib/mysql-files’ (Error 2)

Баг после апгрейда встретился только в Ubuntu

ЕМНИП нужно просто создать каталог /var/lib/mysql-files

‘ERROR 1214 (HY000) at line 784: The used table type doesn’t support FULLTEXT indexes ‘

FULLTEXT INDEX раньше работал только с MyISAM. С версии 5.6 доступен в InnoDB.

Так что либо апгрейд либо ALTER TABLE `yourtable` ENGINE = MyISAM;

Got an error from unknown thread, /builddir/build/BUILD /storage/myisam/mi_write.c:226

Также в логах может быть что-то вроде Incorrect key file for table ‘xyz.MYI’; try to repair it

Казалось бы следует сделать mysqlrepair –auto-repair . Но обычно это не помогает.

Скорее всего нет инодов или кончилось место или недоступен tmpdir в mysql.

Проверяем df -i и df -h . Также проверяем значение tmpdir в my.cnf

mysqldump: Got error: (Errcode: 24) when using LOCK TABLES

Узнал о крутой утилите perror. По коду ошибки покажет, что не так.

Ну и по ошибке выше — попробуйте добавить опцию —single-transaction к mysqldump

Error Number: 1364

Через tcpdump выловил ошибку в php-fpm

Виной всему старый код и новый (5.7) MySQL.

Быстрый фикс — выключить так называемый strict mode

Для этого нужно добавить в my.cnf

Можно также вынести в отдельный файл /etc/mysql/conf.d/disable_strict_mode.cnf

Проверить sql_mode

#1030 — Got error -1 from storage engine

При попытке выполнить SQL запрос в phpmyadmin получаем ошибку #1030 — Got error -1 from storage engine

Вероятно включен innodb_force_recovery в файле my.cnf .

Проверяем логи. Если есть нечто подобное

то значит так оно и есть. Выключаем innodb_force_recovery и всё снова работает.

error: ‘Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)’

Смотрим пароль пользователя debian-sys-maint в файле /etc/mysql/debian.cnf

Выполняем 2 SQL запроса, чтобы вернуть гражданину debian-sys-maint его привилегии

Перезапускаем MySQL сервер

open-files-limit в MariaDB

Systemd самостоятельно контролирует, сколько файлов служба (в нашем случае mariadb-server) может открыть, независимо от того, что вы настроили в /etc/my.cnf или в /etc/security/limits.conf .

И вносим следующие правки

Данные новшества однако документированы. Так что надо просто внимательнее читать release notes и changelog.

Unable to lock ./ibdata1, error: 11

Решение в сети, которое якобы некоторым помогает

увы не помогает.

Бытует мнение, что виной всему Apparmor т.к. нигде кроме Ubuntu ошибка эта не встречалась

Можно попробовать добавить в /etc/apparmor.d/usr.sbin.mysqld

надо проверить

unknown option ‘—skip-locking’

Опцию –skip-locking убрали в MySQL 5.5.

Решение: заменить skip-locking на skip-external-locking

Источник

The error happens when importing database backups using the SOURCE command, either because you got the path wrong, or because you used the command incorrectly.

12394 views

d

By. Jacob

Edited: 2021-01-26 15:34

This is just a quick reminder to those having problems backing up- and importing MySQL databases. Often when I try to import a database using the SOURCE command I will get a SOURCE error 2 message.

The error simply means that we have gotten the file path wrong. However, in my case, it was because I used a less than sign between the SOURCE and the file name.

The reason for my mistake is that I use a greater than sign when backing up a database using mysqldump, and sometimes I mess up because the same logic does not apply when importing. Hopefully I will remember it now.

mysql> SOURCE < /home/username/database_backup.sql

RROR:
Failed to open file ‘< /home/username/database_backup.sql’, error: 2

If you have made the same mistake, simply remove the less than sign from your statement. The SQL statement should look like this:

SOURCE /home/UserName/some_sql_file.sql

The problem can also be that you miss typed the path for the .sql file, though I suppose this is unlikely if you know what you are doing, but be sure to double check this as well.

Alternatively, you can also import databases using mysql in a terminal, in which case you will be using the less than sign:

mysql database_name < database_name.sql

To create a .sql backup of a database, use mysqldump:

mysqldump database_name > database_name.sql

Writing file paths

To understand how to write the file system paths, read this article: Absolute and Relative Paths

Basically, when making backups, you can either write an absolute path for the destination file, beginning with a forward slash «/», or you can use a relative path. Simply writing the file name of the destination file will write the file in the current directory.

You can use the CD command to navigate to the desired location, if you feel more comfortable doing that.

You need to make sure the location is writable when creating a backup. Personally I prefer just outputting to /home/MyUser/databases/name-of-output-file.sql, since I know this will be writable.

  1. How to configure phpMyAdmin with automatic login by setting auth_type to config.

  2. How to create new users in MySQL and control their permissions for better security.

  3. How to generate sitemaps dynamically using PHP.

  4. How to perform simple SELECT statements in SQL to communicate with SQL databases.

More in: MySQL

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find Error: rpmdb open failed on list of servers

Hello all,

I have a task to patch red hat servers and some servers have a corrupted rpm database and return the error:

Error: rpmdb open failed

I know how to fix this when it occurs. What I’m hoping to do is scan a list of servers by IP and report back which server have this error.
(6 Replies)

Discussion started by: greavette

2. Shell Programming and Scripting

Linux open failed: No such file or directory error

Hi, The below commands works fine on serverB

. /etc/profile;
cd /export/home/user2/utils/plugin/
./runme.shHowever, when i run the same commands from serverA it fails

$ ssh -q user2@serverB «. /etc/profile; cd /export/home/user2/utils/plugin; ./runme.sh»Output Error:
Please find the below… (8 Replies)

Discussion started by: mohtashims

3. UNIX for Beginners Questions & Answers

Rdesktop — ERROR: Failed to open keymap en-us

I just updated my rdesktop to 1.8.3 from source ( on Slackware 11 ) and had troubles with arrow keys/page up/page down not working.
I see this on the console:
ERROR: Failed to open keymap en-us

The fix is a permission change. I initially looked at /usr/share/rdesktop/keymaps and everything… (1 Reply)

Discussion started by: agentrnge

4. Infrastructure Monitoring

Puppet open source ERROR 400

Hi! I’ have 2 files:

file test.pp

class copy {
file {«/etc/puppet/files/client1/testfile»:
path => «/home/vassiliy/mytestfile»,
source => «puppet:///mpoint/client1/testfile»,
mode => ‘644’
}
and file site.pp

import «test.pp»
node client1 {
include copy
}
in fileserver.conf (0 Replies)

Discussion started by: vvz

5. Solaris

./curl -V showing fatal: libldap.so.5: open failed: No such file or directory

Hi Guys,

I am facing this Error

bash-2.03$ ./curl -V
ld.so.1: curl: fatal: libldap.so.5: open failed: No such file or directory
Killed
bash-2.03$

while executing

./curl -V in /opt/sfw/bin directory.

I am using Sun Solaris 10.

which package upgrage can give me this missing… (9 Replies)

Discussion started by: manalisharmabe

6. Red Hat

«ERROR : failed to mount nfs source» Red Hat Kickstart

Hi There,

I have been googling for this error and try solution provided but still not avail to resolve Kickstart Issue.

Any expert have encounter this problem? Thanks.

Regards,
Regmaster (4 Replies)

Discussion started by: regmaster

7. Solaris

Error- ld.so.1: expr: fatal: libgmp.so.3: open failed:No such file or directory

Hi Friends

I have a compiler(Sun Forte,I believe) running in my Solaris 9 box.
since y’day my development team is finding this error when they compile:

ld.so.1: expr: fatal: libgmp.so.3: open failed: No such file or directory

I ran a search for this file and found it in one of my file… (2 Replies)

Discussion started by: Hari_Ganesh

8. Solaris

Error:: libm.so.2:open failed

Hi,

I am working with solaris 9 and I want to install perforce on that,so I downloaded the p4v.bin file and try to install it by the command

./p4v

after that it is giving the error—

ld.so.1: ./p4v.bin: fatal: libm.so.2: open failed: No such file or directory
Killed

I am not… (3 Replies)

Discussion started by: smartgupta

9. Shell Programming and Scripting

Failed to open output file Error

Hi guys,
I Have written a script,In that it will call another file which contains the sql quaries.

while wxecuting that I am getting the below exception
01/16|06:28:06:16800: Operating System Error|Failed to open output file

Can anybody help me about this,,Its urgent (0 Replies)

Discussion started by: Anji

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Linux error unable to access jarfile
  • Linux error too many open files
  • Linux error reading lock file
  • Linux error occurred during initialization of vm java lang noclassdeffounderror java lang object
  • Linux error no such partition

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии