473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Still having difficulty running MySQL's 'source' command

MLH
I am having failures processing the following command and I wonder
if you can tell me what I must do in order to have success. When I try
to run source mysql_dump.sql.txt ==> it is a problem for me.

1) I put the file in /home/mlh/public_html/credifree/sql_script/.
2) I made that directory my current directory
3) I typed mysql and pressed ENTER
4) I then typed source mysql_dump.sql.txt and pressed ENTER

A bunch of error messages saying
ERROR 1046: No Database Selected
filled up the screen.

Well, of course there was no database selected. I do not yet have a
database. I thought the whole point of running
source mysql_dump.sql.txt
was to CREATE a set of database files on my linux box. Is that
incorrect? What must I do to avoid this error 1046?
And now, the last question...
Can you tell me where the database files will be placed when running
source mysql_dump.sql.txt as I described above from the same current
directory as described above? I do wish to KNOW in advance where the
files will be created.

Jul 23 '05 #1
4 11468
MLH wrote:
I am having failures processing the following command and I wonder
if you can tell me what I must do in order to have success. When I try
to run source mysql_dump.sql.txt ==> it is a problem for me.

1) I put the file in /home/mlh/public_html/credifree/sql_script/.
2) I made that directory my current directory
3) I typed mysql and pressed ENTER
4) I then typed source mysql_dump.sql.txt and pressed ENTER

A bunch of error messages saying
ERROR 1046: No Database Selected
filled up the screen.

Well, of course there was no database selected. I do not yet have a
database. I thought the whole point of running
source mysql_dump.sql.txt
was to CREATE a set of database files on my linux box. Is that
incorrect? What must I do to avoid this error 1046?
Presumably your file doesn't have any create syntax in it so you need to
create the database first like so:

create database <database name>;
use <database name>;
source mysql_dump.sql.txt;
And now, the last question...
Can you tell me where the database files will be placed when running
source mysql_dump.sql.txt as I described above from the same current
directory as described above? I do wish to KNOW in advance where the
files will be created.


Depends on the configuration of MySQL. On my machine they're
in /var/lib/mysql. Why do you want to know where the files are though?
You won't be able to do anything with them because they're binary
files. If you want to back up your database you should use the
mysqldump command.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 23 '05 #2
MLH wrote:
I thought the whole point of running
source mysql_dump.sql.txt
was to CREATE a set of database files on my linux box. Is that
incorrect? What must I do to avoid this error 1046?
Some dump files contain the "create database ..." command in them, but
this is optional. It depends on whether the person who produced the
dump file chose that option.

If the script doesn't do it for you, you can create an empty database
and then run the script to create tables and data within that database.

Read this page from the tutorial, and its subsections:
http://dev.mysql.com/doc/mysql/en/database-use.html

I really recommend that you start reading the documentation, especially
the tutorial, to which I have referred you twice. MySQL docs are better
than many, and they can answer a lot of these beginning issues for you
much more quickly than newsgroups can. Newsgroups are best for sticky
issues that aren't covered well in docs.
mysql databasename < directory/containing/script/mysql_dump.sql.txt
I tried it. I got an error msg. Here is the error...
ERROR 1044: Access denied for user: '@localhost' to database 'mydatabase'
This most likely indicates that on your machine, anonymous database
connections have been disabled; you must therefore specify a username
when connecting to a MySQL database, using the "-u username" option.
ERROR 1045: Access denied for user: 'mlh@localhost' (Using Password: YES) The mlh user is my non-root linux userID.
MySQL usernames have nothing to do with operating system logins. You
can create a MySQL username that is the same as your Linux login, but it
is not present by default.

Read this page for more information on creating usernames in MySQL:
http://dev.mysql.com/doc/mysql/en/adding-users.html
And now, the last question...
Can you tell me where the database files will be placed when running
source mysql_dump.sql.txt as I described above from the same current
directory as described above? I do wish to KNOW in advance where the
files will be created.


The location of your data directory depends on your system
configuration. It varies from installation to installation where the
physical files are kept.

And in any case, there's no way to infer the data directory from the
path where your script is.

All MySQL databases on a given host are stored under a location known as
the data directory, or datadir. Each database's files are stored in a
subdirectory off the datadir, according to the name you define for the
database. You can ask MySQL where its data directory is currently defined:

mysql> show variables like 'datadir';

Regards,
Bill K.
Jul 23 '05 #3
MLH
On Sun, 27 Mar 2005 06:39:58 +1200, Chris Hope
<bl*******@electrictoolbox.com> wrote:
MLH wrote:
I am having failures processing the following command and I wonder
if you can tell me what I must do in order to have success. When I try
to run source mysql_dump.sql.txt ==> it is a problem for me.

1) I put the file in /home/mlh/public_html/credifree/sql_script/.
2) I made that directory my current directory
3) I typed mysql and pressed ENTER
4) I then typed source mysql_dump.sql.txt and pressed ENTER

A bunch of error messages saying
ERROR 1046: No Database Selected
filled up the screen.

Well, of course there was no database selected. I do not yet have a
database. I thought the whole point of running
source mysql_dump.sql.txt
was to CREATE a set of database files on my linux box. Is that
incorrect? What must I do to avoid this error 1046?


Presumably your file doesn't have any create syntax in it so you need to
create the database first like so:

create database <database name>;
use <database name>;
source mysql_dump.sql.txt;

You are correct! There were lots of instances of CREATE TABLE but none
of CREATE DATABASE in the dump file. I tried to do what you said. I
typed mysql under my user login and pressed ENTER. The mysql> command
prompt appeared. I typed create database mydb and pressed ENTER. Here
is the error I got...
ERROR 1044: Access denied for user: '@localhost' to database 'mydb'

So, I exit'd mysql back to linux command prompt and logged in as the
super user and tried again. Here's the error I got typing mysql and
pressing ENTER...
ERROR 1045: Access denied for user: 'root@localhost' (Using password:
NO)
It seems I can't win for losing!

And now, the last question...
Can you tell me where the database files will be placed when running
source mysql_dump.sql.txt as I described above from the same current
directory as described above? I do wish to KNOW in advance where the
files will be created.


Depends on the configuration of MySQL. On my machine they're
in /var/lib/mysql. Why do you want to know where the files are though?
You won't be able to do anything with them because they're binary
files. If you want to back up your database you should use the
mysqldump command.


Its a force of habit, really - from the old DOS days. If it is not
important, then I won't lose any sleep over it. But I would be curious
to know what files are created and where.
Jul 23 '05 #4
MLH
<snip>
I really recommend that you start reading the documentation, especially
the tutorial, to which I have referred you twice. MySQL docs are better
than many, and they can answer a lot of these beginning issues for you
much more quickly than newsgroups can. Newsgroups are best for sticky
issues that aren't covered well in docs. Could you refer it one more time, just for good measure? <grin> I'm
only kidding. I appreciate you suggestions and I did read it the first
time. I believe the problem I should have asked for help on is likely
a security issue more basic than not being able to run the source
command. Please pardon my ignorance in both the linux and MySQL
environments as well as this darned newsreader of mine.
mysql databasename < directory/containing/script/mysql_dump.sql.txt
I tried it. I got an error msg. Here is the error...
ERROR 1044: Access denied for user: '@localhost' to database 'mydatabase'


This most likely indicates that on your machine, anonymous database
connections have been disabled; you must therefore specify a username
when connecting to a MySQL database, using the "-u username" option.

Thx Bill.
ERROR 1045: Access denied for user: 'mlh@localhost' (Using Password:

YES)
The mlh user is my non-root linux userID.


MySQL usernames have nothing to do with operating system logins. You
can create a MySQL username that is the same as your Linux login, but it
is not present by default.

Read this page for more information on creating usernames in MySQL:
http://dev.mysql.com/doc/mysql/en/adding-users.html

Yes, I will read that section. The guy I bought the server from loaded
with linux, Apache, PHP and MySQL. I am uncertain what outstanding
'do-items' might still remain pertinent to the MySQL installation. Its
likely that some 'holes' exist that I'm not aware of. Tasks I'm
attempting now are probably reliant on certain prerequisites having
been completed. I'm working backwards to find out what wasn't
done that still needs to be done.
And now, the last question...
Can you tell me where the database files will be placed when running
source mysql_dump.sql.txt as I described above from the same current
directory as described above? I do wish to KNOW in advance where the
files will be created.


The location of your data directory depends on your system
configuration. It varies from installation to installation where the
physical files are kept.

And in any case, there's no way to infer the data directory from the
path where your script is.

All MySQL databases on a given host are stored under a location known as
the data directory, or datadir. Each database's files are stored in a
subdirectory off the datadir, according to the name you define for the
database. You can ask MySQL where its data directory is currently defined:

mysql> show variables like 'datadir';

Regards,
Bill K.

10-4. I appreciate your comments, Bill.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jon rogers | last post by:
Thanks for the advice I got, but I still cannot install PHP. >./configure --with-mysql --with-apxs2=/path/to/apxs2 > >http://uk.php.net/manual/en/install.apache2.php So what is my...
8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
1
by: George | last post by:
Hi, I am trying to write a query in Oracle which I have not done before, and are having some difficulty getting my result. Please check my query and my results. select max(note.datetime),...
4
by: Nick Kerzman via MySQLMonster.com | last post by:
Any assistance would be greatly appreciated. I'm relatively new to working with MySQL. I exported my DB with phpMyAdmin 2.6.0-pl3 running MySQL 4.1.7 I'm trying to import it with phpMyAdmin...
7
by: MLH | last post by:
I have an sql script file that is supposed to create a set of database tables for me. Supposedly I type the following on my linux box and its all supposed to work... mysql (ENTER) \....
687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
14
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
3
by: apostolosl | last post by:
Hi there. I need to update a remote database from a local one. I use mysqldump in my php page in order to create a file for each table, like this: $command="mysqldump table_products >...
7
by: ted clarke | last post by:
hello. i am running mysql5 on mac osx 10.5. i am new to both of these. i have created a sql script file and i am trying to use it with the sql SOURCE command. when i execute the command: SOURCE...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.