473,729 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do I create a database on linux machine running mysql?

MLH
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)
\. mysql_dump.sql. txt

When I type myslq <ENTER> I get a command prompt
that looks like this...

mysql>

But I don't know how to change directories from that
command prompt to the directory where mysql_dump.sql. txt
is located. Can someone tell me how to change dirs at
the mysql> prompt?
Jul 23 '05 #1
7 2104
MLH wrote:
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)
\. mysql_dump.sql. txt

When I type myslq <ENTER> I get a command prompt
that looks like this...

mysql>

But I don't know how to change directories from that
command prompt to the directory where mysql_dump.sql. txt
is located. Can someone tell me how to change dirs at
the mysql> prompt?


From the command line to load a mysql dump file do this:

mysql -u [username] -p [database_name] < [filename]
eg
mysql -u someuser -p somedb < mysql_dump.sql. txt

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 23 '05 #2
MLH,
There is a good book called MySQL written by Paul DuBois, it has
tutorials and stuff. It seems like you are new to databases from the
question you asked. I highly recommend you getting the book and learn
this fun stuff if you have the inclination to absorb this technology.

usaims

Jul 23 '05 #3
usaims wrote:
There is a good book called MySQL written by Paul DuBois, it has
tutorials and stuff.


There's also a MySQL tutorial online at:
http://dev.mysql.com/doc/mysql/en/tutorial.html

With regards to loading data from the script, there are several choices:

One option is to cd to the directory before you run the mysql tool:
$ cd directory/containing/script
$ mysql
mysql> source mysql_dump.sql. txt

Another option is to use the path to the dump file:
$ mysql
mysql> source directory/containing/script/mysql_dump.sql. txt

Another option, as Chris Hope pointed out, is to run the script directly
from the command line:
mysql databasename < directory/containing/script/mysql_dump.sql. txt

(you also might need to specify "-u username" and "-p", if the database
is configured to require a non-anonymous login and password)

Regards,
Bill K.
Jul 23 '05 #4
Bill Karwin wrote:
usaims wrote:
There is a good book called MySQL written by Paul DuBois, it has
tutorials and stuff.


There's also a MySQL tutorial online at:
http://dev.mysql.com/doc/mysql/en/tutorial.html

With regards to loading data from the script, there are several
choices:

One option is to cd to the directory before you run the mysql tool:
$ cd directory/containing/script
$ mysql
mysql> source mysql_dump.sql. txt

Another option is to use the path to the dump file:
$ mysql
mysql> source directory/containing/script/mysql_dump.sql. txt

Another option, as Chris Hope pointed out, is to run the script
directly from the command line:
mysql databasename < directory/containing/script/mysql_dump.sql. txt

(you also might need to specify "-u username" and "-p", if the
database is configured to require a non-anonymous login and password)


I hadn't seen that "source" one from within the mysql command prompt
before. That's really cool. Thanks Bill.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 23 '05 #5
MLH
Thank-you for suggesting this syntax...
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'

I was not logged in as root at the time of running the command.
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxx
<snip>

Another option, as Chris Hope pointed out, is to run the script directly
from the command line:
mysql databasename < directory/containing/script/mysql_dump.sql. txt <snip>Regards,
Bill K.


Jul 23 '05 #6
MLH
I tried cd'ing to the directory containing mysql_dump.sql. txt,
running mysql <ENTER> and finally source mysql_dump.sql. txt.
A bunch of error messages saying
ERROR 1046: No Database Selected
filled up the screen.
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxx

One option is to cd to the directory before you run the mysql tool:
$ cd directory/containing/script
$ mysql
mysql> source mysql_dump.sql. txt

Another option is to use the path to the dump file:
$ mysql
mysql> source directory/containing/script/mysql_dump.sql. txt

Another option, as Chris Hope pointed out, is to run the script
directly from the command line:
mysql databasename < directory/containing/script/mysql_dump.sql. txt

(you also might need to specify "-u username" and "-p", if the
database is configured to require a non-anonymous login and password)


I hadn't seen that "source" one from within the mysql command prompt
before. That's really cool. Thanks Bill.


Jul 23 '05 #7
MLH
I tried the following syntax
mysql -u mlh -p mydatabase < mysql_dump.sql. txt
and received the following error msg...

ERROR 1045: Access denied for user: 'mlh@localhost' (Using Password:
YES)

The mlh user is my non-root linux userID. The recommended syntax
shown below indicates 'someuser' and mlh is what I used. Also, it
indicates 'somedb'. I used 'mydatabase' as the name, since I am
doing this for test purposes now. Since I don't have a database yet
(running this script is supposed to create one) I assume the name I
use in place of somedb will be the name of the database that's created
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxx
<snip>

From the command line to load a mysql dump file do this:

mysql -u [username] -p [database_name] < [filename]
eg
mysql -u someuser -p somedb < mysql_dump.sql. txt


Jul 23 '05 #8

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

Similar topics

6
6488
by: Eric W. Holzapfel | last post by:
Hello PHP group, I have mysql running on a linux box. I have apache (2.0.4) running on a diff linux box. I have php 4.X. I can connect to the mysql db using odbc from a windows box, but cannot connect to the remote db from web server box (linux) to mysql database (another linux box). Apache is on RH Enterprise 3.0, mysql is on slacware (2.4.22 kernel). I am using php, require_once('DB.php'), and the dsn style connect string:...
0
2197
by: Carl B. Constantine | last post by:
I'm trying to move a database from one machine to another. I dumped the database and successfully loaded it on one machine, but I can't do it on another machine. I have the database set up. I created the user to access the database, and gave all privs with grant option for that database. But when I go to run the command to restore the database, I get the following error: $ mysql -u user -p database < database.sql Enter password:
13
2954
by: torjon | last post by:
I need to 1)Copy an entire mysql database, including table structres and data 2)install it into anotehr mysql db on another machine How? Or at lease direct me to net resources about this.
0
1812
by: Scott | last post by:
Hi, I'm having a problem with a new machine running Mysql version 4.0.18 on the AMD64 version of Mandrake 10.0. The new machine has got 64bit AMD processor and 2GB of RAM. Nearly all queries(updates are especially slow) are running 20/30 or more times slower than on an inferior(32 bit processor, 1.5GB RAM) machine runnning Mysql 3.23.56 on mandrake 9.0.
0
1160
by: timothy.williams | last post by:
We have mysql running on a Linux server now, but an exercise we are running are causing this machine to bog down. We'd like to just shut down the server on this machine and start it up on another using the same database. The setup between the two machines (both Linux RedHat) are essentially the same. The database is on a separate file server. Are there any problems in doing this? I would rather not have to dump the database from one...
0
1549
by: Peter Chant | last post by:
I hope no one minds me running this past them. I'm running a linux machine with with apache, php and mysql. This is not accessable from the internet. I want a server that is visable to the internet. For that purpose I am running a user mode linux machine and using apache on that as the external looking web server. This means that stuff I want to see on the outside is on a copy of apache that is doing little and does not get messed...
6
3362
by: GD | last post by:
Hi All, I've got MySQL 5.0.21 running on Windows Server 2003, and php running on Apache on a Linux box (Fedora Core 4). Previously when the pages were running on an IIS server the connection was succesful, now I get: Can't connect to MySQL server on 'SERVER' (13)
14
6134
by: mistral | last post by:
Need php script to create mySQL database programmatically; since hosting configuration may not allow create database from script, script also need eliminate/rewrite all restrictions in appropriate places in that hosting.
12
3943
by: grace | last post by:
i am wondering why my database retrieval becomes too slow...we set up a new server (ubuntu, breezy badger) machine where we transferred all our files from the old server.. Our new server uses Asus p5pe-vm motherboard and an Intel Pentium D 3.0Ghz processor, compared to the old one where we uses asrock motherboard and AMD Duron. Both has the same version of mysql installed... To summarized, both machine has the same configuration except...
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.