PDA

View Full Version : How To Import SQL?



Titan85
08-09-2006, 06:27 PM
I have been trying to learn some php and a lot of the tutorials say to import some lines to the SQL tables via phpmyadmin. For example, import this code into a MySQL table:
Create TABLE `stats` (
`ID` tinyint(11) NOT NULL AUTO_INCREMENT,
`IP` varchar(18) NOT NULL,
`referer` varchar(255) NOT NULL,
`time` varchar(30) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY(`ID`))
TYPE = MyISAM;

I know how to get into phpmyadmin and all that, but where do i go in order to import lines?

Twey
08-09-2006, 10:52 PM
This code is the output of a tool called mysqldump. This tool generates the SQL necessary to create a table. You can just execute it under the "SQL" tab in phpMyAdmin like any other query.

However, I suggest dropping phpMyAdmin in favour of the default command-line client. You'll get a much better feel for the language.

Titan85
08-10-2006, 12:51 AM
This code is the output of a tool called mysqldump. This tool generates the SQL necessary to create a table. You can just execute it under the "SQL" tab in phpMyAdmin like any other query.

However, I suggest dropping phpMyAdmin in favour of the default command-line client. You'll get a much better feel for the language.Thanks, looked at it and there it was, plain and simple to see if you know what your lookin for :) . What do you mean by default command-line client?

Twey
08-10-2006, 01:10 AM
When you install the MySQL server, a client is installed too, called simply mysql. This should be run from a command-line (mysql -p -u <yourusername> -h <host>) and you can then modify your database by executing MySQL queries in real-time.

BLiZZaRD
08-10-2006, 12:08 PM
Hijacking this thread...

I am using putty for most of my sqldumps. I am using this code:

mysqldump --allow-keywords --opt -u<username> -p<pass> <user_dbname> > /path/to/dump/to/<name of file>.sql

It works perfect everytime.

BUT! I was wondering 2 things:

1) is it possible to get a gzip.sql and if so what do I change?

2) what does --allow-keywords --opt mean?

Twey
08-10-2006, 06:59 PM
1) is it possible to get a gzip.sql and if so what do I change?Not directly, no. Chain it with the gzip command:
mysqldump --allow-keywords --opt -u<username> -p<pass> <user_dbname>|gzip > /path/to/dump/to/<name of file>.sql.gz
2) what does --allow-keywords --opt mean?Read the manpages :p

--opt

This option is shorthand; it is the same as specifying
--add-drop-table --add-locks --create-options --disable-keys
--extended-insert --lock-tables --quick --set-charset. It should
give you a fast dump operation and produce a dump file that can be
reloaded into a MySQL server quickly.
--allow-keywords

Allow creation of column names that are keywords. This works by
prefixing each column name with the table name.

Titan85
08-10-2006, 11:46 PM
Thanks for the help. I'll have a look at simply mysql

Twey
08-10-2006, 11:57 PM
No no. I mean it's simply called "mysql", not that it's called "simply mysql" :)
I apologise for resulting confusion.

BLiZZaRD
08-11-2006, 03:47 AM
Thanks Twey... I will read the "manpages" when my wife and kids aren't around :p

Twey
08-11-2006, 03:54 AM
In the bsd-games package on Gentoo, there's a rather obscure program called "sex." I recommend it to everyone just so I can have the joy of telling them what to type when they ask how to use it.

BLiZZaRD
08-11-2006, 09:24 AM
is there an RPM for the FC5 release? I will get it if so. I would look now, but I am at work.. can you imagine the IT guys looking at my Google searches with that key word? LMAO

Twey
08-11-2006, 04:51 PM
Unfortunately, I couldn't find one.
Oh well, it's not actually useful or anything. :p