Results 1 to 5 of 5
Hi all, first off my apologies for what is probably a very basic question but I am pretty stumped as Im used to Windows and Windows Server. Last night I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-12-2013 #1
- Join Date
- Jan 2013
Linux Noob, (stupid question)
Last night I installed Ubuntu Server and set it up as a web server on a Virtual Machine. That all went fine. I have installed mySql, surprisingly easier than doing it on windows.
However I have now run into a problem with a sql script file.
I am user stewart. When I log onto my web server, I get the following prompt
stewart at web-server:~$
I have created a directory call SQL
when I use the ls command the only directory that pops up is SQL.
Within the SQL directory is a file I have created called
Now when I go into mysql I have tried the follwing commands
None of which work and I am hitting a brick wall for something that should be relatively easy. I could use mySQL in windows instead but I would like to get used to Linux as we have it at work and I am going to have to use it sooner or later.
Thanks in advance for any help
- 01-12-2013 #2
hi and welcome
source (mark the lower case, linux is case sensitive) is used by e.g. bash to read a bash script.
But to pass sql statements from a file to mysql you would use something like
mysql < /home/SQL/create-tbl.sql mysql < DB_NAME /home/SQL/create-tbl.sql
- The mysql daemon must be started
- Your user need to have the correct *mysql* privileges to create/modify a db
- mysql users are different than system users.You must always face the curtain with a bow.
- 01-12-2013 #3
Your home directory will be /home/stewart. User directories are always created under /home. The new directory that you created is inside your home directory so it will be /home/stewart/SQL.
But you don't need to type that in full each time. Did you notice the little squiggle ~ at the end of your bash prompt? That is short for "my home directory". It occurs there to show that your current working directory is your home directory. If you had moved into your SQL sub-directory, you would have seen "~/SQL" as the current working directory. So if you want to refer to it, "~/SQL" will also do. Now compare the three forms you used with the correct forms and you should see at once why they are wrong.
There are no stupid questions. There are only opportunities to learn, and stupid people who won't learn."I'm just a little old lady; don't try to dazzle me with jargon!"
- 01-12-2013 #4
- Join Date
- Jan 2013
- 01-12-2013 #5
- Join Date
- Jan 2005
- Saint Paul, MN
"source" is a way for bash (the command line interface) to read bash commands and execute them. I would assume that the the "*.sql' files are for a database and you will have to use the database program to process them. For example if you were using Postgresql the command would be:
psql -f ~/SQL/create-tbl.sql or cd psql -f ./SQL/create-tbl.sql or cd ~/SQL psql -f create-tbl.sql or cd cd SQL psql -f create-tbl.sql and so one
As for your reference for the file, all three are incorrect, which you would have found out if you would have attempted to use cd to find the path.
cd / ls
cd home ls
cd stewart ls
Here are several ways to reference the HOME directory, such as:
~penelope/ --- the HOME directory for user "penelope" ~/ --- my HOME directory ~-/ --- the directory I was in just before changing to the current directory