Can't find .sql file in sql query phpmyadmin (#13 Error) - php

I am trying to import a cities .sql file into my table.
I am using this github repository:
https://github.com/JoshSmith/worldwide-city-database
I have created the table, like it says in the repository,
but when it comes to importing the cities.sql I get an error.
LOAD DATA INFILE "/tmp/test_data/cities.sql"
INTO TABLE cities
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
(combined, population, country_code, region, latitude, longitude);
I also have a picture of it:
I mention that I am using a Mac, have read all the solutions and tried them out, but didn't work. I also made sure my file is in MAMP/tmp/.
EDIT: Sorry for the confusion from the image -> sql query. I have the file in /tmp/test_data/ . I have modified the query to look there.

You have the cities.sql? then you need to create new database ,give name:cities then import into cities your cities.sql file.

You indicated you had the file in MAMP/temp/ ...but the error indicates it's looking for the file in /tmp/test_data/. Check your tmp vs temp.

I suggest that you use the phpMyAdmin UploadDir feature instead. Due to various permissions issues, security means, and other idiosyncrasies those processes can be blocked from reading this file even though you provide the complete path. Using the phpMyAdmin UploadDir, you basically create a folder (mine is a subdirectory of my phpMyAdmin installation), add the directive to config.inc.php, and copy the file in there. phpMyAdmin shows it in a dropdown on the Import page. Again, you need proper permissions on the file and folder, but I find it easier than LOAD DATA INFILE.
If you prefer to continue to try the MySQL method, my guess is that it's a permissions problem. Make sure the webserver and MySQL processes have the proper permissions on the .sql file (and perhaps also on the directory it's in, though that probably shouldn't matter). Your webserver and MySQL error logs might have hints, also.

Related

Can't export SQL files

I'm having a problem with exporting SQL files. When I click go it just opens the sql file with notepad, here's a pic:
The (9) shows how many times i've downloaded the file. I also can't see the file on my downloads folder.
You might have a problem with your phpmyadmin , please try use cmd or terminal to export all your databases and reinstall phpmyadmin again. This might fix the issue. To export using cmd or terminal use code below:
You should use mysqldump, since it tries to do the data dump without blocking the database tables.
mysqldump -u [username] -p [database-you-want-to-dump] > [path-to-place-data-dump]
So it could be something like this:
mysqldump -u root -p mydatabase > /home/myuser/database-dump.sql
If you are getting SQL dumps in notepad then you are actually getting the SQL dump. I think only problem is you cant find the downloaded file because you must have specified different folder for saving downloaded files. Check your browser settings. Press Ctrl+J to see the recent downloads. Or easiest is copy that open notepad contents to new file and save as you want.
The big question here is: Do you want to solve your problem and not just workaround it with console?
I really think this is a windows/browser problem - not a PHPMyAdmin problem.
Looking at the line you have in that Notepad - I see bits of SQL for table creation and column data in your screenshot. It looks like a working dump. Your notepad view is very wide - most of the data is cut off.
On Notepad- Format->Word Wrap and compare it with a console dump. I have a feeling both files will be identical.
Next step - what browser are you using?
If you're using Chrome, you can go into settings and have it ask where to save the file before downloading (This setting: "Ask where to save each file before downloading"). That will let you switch the download location from your %appdata%/roaming to wherever you want.
Apparently - in the current version of Chrome, this setting will stop auto-opening.
Once you try getting that setting turned on ... try turning it off. It may just clear your problem as it did for the poster in the Chrome product forum.

Can't drop a database even though it has no content

I'm trying to clear out old databases on my PC (had them for past projects) and whenever I try and drop any of them, I get the following error:
#1010 - Error dropping database (can't rmdir '.\aroma_cafe', errno: 41)
It looks to me as if the system is attempting to delete a directory/folder that doesn't exist. Have you already removed it manually? It could be that each database is stored in a directory and a list of all databases in some other file.. so if you have gotten rid of that data, only the reference remains.
I think there are files within that directory that is not related to
MySQL. One scenario might be, insufficient permissions. You might want
to delete that directory from the filesystem.
Should do comment though.

LOAD DATA INFILE Directory Structure

I've been scouring the internet and attempting to troubleshoot this issue for hours and finally caved and decided to ask for help directly.
I'm running a linux dedicated server and need to load data into my mysql database by running a mysql query executed from a php page on the host machine.
The problem I'm having is I have no idea what the directory structure needs to look like in order to actually find my file and have it be uploaded. I'll give an example below.
LOAD DATA INFILE 'WHAT IN THE WORLD GOES HERE TO MAKE THIS WORK?'
INTO TABLE customers
The error that returns every time I try to run this is
Error Code: 1045. Access denied for user
I've already checked the permissions and the user has FULL permissions on the appropriate database. From my own research I have found that it can throw this error for a few reasons, one of which being that it cannot find the file I am trying to upload.
My file structure after you get into the public_html folder is as follows:
reports/uploads/fileName.csv
Thanks for any help in advance! This has been driving me insane. If I've just been doing this entirely the wrong way, or there is an easier way to accomplish what I am doing I'm also open to suggestions on that front.
As explained in the documentation:
If the file name is an absolute path name, the server uses it as given.
If the file name is a relative path name with one or more leading components, the server searches for the file relative to the server's data directory.
If a file name with no leading components is given, the server looks for the file in the database directory of the default database.
The public_html folder is irrelevant, since the file is being read by the MySQL server. If your webserver and database servers are different machines, and you're trying to load a file from the client, not the server, you need to use LOAD DATA LOCAL INFILE to specify that. Then the filename will be interpreted relative to the working directory of the client application.
Some thoughts: to use LOAD DATA INFILE on a file present on the server, the user performing the load data must have the FILE privileges. If the file is present client side, use LOAD DATA LOCAL INFILE.
This link is useful: http://dev.mysql.com/doc/refman/5.1/en/load-data.html
It's usually good to test the LOAD FILE with a file in an easily accessible location, such as /tmp to confirm that the privileges are okay. Then you can start to debug access issues to the location where your real file is located.
Hope this helps.

Can't update the file after deleting conflicted file (the local one) with TortoiseSVN

I'm using TortoiseSVN. Recently there is a file in conflicted state. I right click it, choose 'Edit conflict', then choose 'Delete local file'.
I thought after deleting the local file, I could update to get the file from SVN server. But the fact is that TortoiseSVN doesn't let me get the file on server down to my local computer.
TortoiseSVN just shows that there are no changes.
I need the latest version of that file from server!!!
If you want to get the version of the server, the easiest way is to
revert your local copy (if there are any changes in that directory or below, you will loose these, but if that conflict is the only problem, it helps. To do that, do the following:
Select Revert... from the menu
In the opening dialog, accept that the file is reverted.
You now have a local copy without changes, so there should be no conflict there.
Now update that file to the current state of the repository.
If that does not work for the file itself, try to to if for the directory where the file lays in. Normally, it should be possible for this directory (with the conflicted state) to be reverted ...
I hope this order of actions works under any circumstances.
For editing conflicts... You need to open Edit Conflict panel and select the portions of the code you want to keep.
In case you delete a file, try importing that file again. If it doesn't work you need to make a fresh working copy.
Assuming the original local file is in your Recycle Bin, I would restore it. Then, try updating again, but this time say "resolve using theirs." It should replace your local copy with the head copy.

Where do I hide my login info when using PHP connect to get to a database?

I need to connect to a mysql database using PHP. I am storing my login, user, password, and other info in a separate php file (let's say "mysql_connect.php") and then accessing it via require_once (mysql_connect.php) in a different file.
I have done a bit of googling and I know that I am supposed to keep "mysql_connect.php" out of the web root. I have moved it outside of the html folder and tried calling to it by using "../../mysql_connect.php" This is not working, it gives me an error "function not found" or something like that. Upon googling that, the internet says that its because it can't locate the file i'm referencing. When I move mysql_connect.php into a folder below root, everything works fine. The issue is because it is moved outside of the web root (i think).
I have been googling for two days now and cannot find a detailed explanation on how to get this to work. Something about changing the .htaccess file? I've read a bunch of articles on the theory but I am really looking for a step-by-step tutorial (I am a beginner). The only step-by-step tutorials I can find just tell you to put the config.php file into the same folder which is not secure.
Also in reading, it says that putting mysql_connect.php above root might not be THE most secure way to store the information as it is still basically just a .txt file and it can be retrieved easily(like downloading it). I am looking for a balance between secure and also do-able (for a beginner like myself). The mysql database I am trying to protect will not have any personal information and I plan on using a dedicated server (with no other information on it).
Can any one help me to solve this issue?
it gives me an error "function not found" or something like that.
This.
Is your main problem.
You either didn't bother to read this error message yourself nor didn't bring it here to help us to help you.
While
there is no problem in having this file below document_root,
and there is no problem in having this file above document root either,
the only problem you have is to assign a correct filename.
And the error message you got could help you more than 1000 volunteers from this site.
Despite of that, you can use PHP predefined variable to make this path work from whatever part of your site. Aassuming the file is one level above the document root, the code would be
require($_SERVER['DOCUMENT_ROOT']."/../mysql_connect.php");
however, this one may produce an error too, as nobody knows a real file locations. Thus, you may read the error message and corect the paths. Or post it here and get an interpretation
You can store the database information inside your web server configuration.
If you run Apache you can use SetEnv inside the VirtualHost. Since you're still on a shared host, your server admin probably need to help you with this. You can read more about this approach here.
... tried calling to it by using "../../mysql_connect.php" This is not working, it gives me an error "function not found" or something like that.
Include the connection details with:
require_once("../../mysql_connect.php");
This assumes that the file mysql_connect.php is two levels up from the currently executing script.
The database connection details will always be able to be read by whomever has administrative access to the server. It is not feasible to encrypt the file, because you would still need to store whatever key or password needed to decrypt it on the server as well, which would still not hide it from the server administrators.
Besides moving out of the web-root (which is a good step forward) an approach I've seen used is:
// at the top of your index or bootstrap file
define('SECURED', true);
And:
// at the top of any file subsequently included, such as mysql_connect.php
if(!defined('SECURED'))
{
exit();
}
This will at least prevent the file(s) from being accessed (executed) directly. This is helpful is the to-be-included files would otherwise issue a warning or error, that could potentially dump sensitive data as output.
If you're in a shared hosting environment you won't be allowed access outside of document root (most likely). You will need the password therefore it won't be completely secure. Instead, you can look into creating seperate mysql users with priviledges and limiting connections to to local accesses only.
i know i'm new, but something as simple as form for your login should be checked in order for it to work.
<form action="insertphpfilepath.php" method="POST">
and then in "insertphpfilepath.php", would have the mysql_query to check the login and password, not forgetting the mysql_query for connecting to the database and table using the right username and password .
a newbie recommendation to you for use mysql_real_escape_string for any $_POST['login'] so that it would become $login=mysql_real_escape_string($_POST['login']); for evading mysql injection.

Categories