Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: How To Import SQL?

  1. #1
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post How To Import SQL?

    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?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    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?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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?
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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:
    Code:
    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
    Quote Originally Posted by mysqldump(1)
    Code:
         --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.
    Code:
         --allow-keywords
    
              Allow creation of column names that are keywords. This works by
              prefixing each column name with the table name.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the help. I'll have a look at simply mysql

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No no. I mean it's simply called "mysql", not that it's called "simply mysql"
    I apologise for resulting confusion.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Thanks Twey... I will read the "manpages" when my wife and kids aren't around
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •