Importing a MySQL database: Difference between revisions

>Samthecrazyman
Created, from Dokuwiki
 
>Samthecrazyman
m Changed numbering to bullet points
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:


== Importing your database ==
== Importing your database ==
# If not at the console shell, open a console shell (Konsole in KDE)
* If not at the console shell, open a console shell (Konsole in KDE)
# First we need to use the main MySQL administration program. To run this type the following:<code># mysql -u [username] -p</code>For example, to login as root, type the following:<pre># mysql -u root -p</pre>
* First we need to use the main MySQL administration program. To run this type the following:<code># mysql -u [username] -p</code>For example, to login as root, type the following:<pre># mysql -u root -p</pre>
# Enter your password when prompted.
* Enter your password when prompted.
# At the MySQL prompt type the following:<pre>mysql> create database [database name];</pre>For example, to create the database named 'wikidb' type:<pre>mysql> create database wikidb;</pre>
* At the MySQL prompt type the following:<pre>mysql> create database [database name];</pre>For example, to create the database named 'wikidb' type:<pre>mysql> create database wikidb;</pre>
# If successful, you should see the following response:<pre>Query OK, 1 row affected (0.00 sec)</pre>
* If successful, you should see the following response:<pre>Query OK, 1 row affected (0.00 sec)</pre>
# Now close MySQL by typing:<pre>mysql> exit</pre>MySQL will return<pre>Bye</pre>
* Now close MySQL by typing:<pre>mysql> exit</pre>MySQL will return<pre>Bye</pre>
# At the console shell type the following:<pre># mysql -u [username] -p [database name] < [path to file/file.sql</pre>For example, if the username is root, the database name you just created is wikidb and the path the the dumped SQL file is the Linux root home directory, type the following:<pre># mysql -u root -p wikidb < /root/Documents/wikidb.sql</pre>
* At the console shell type the following:<pre># mysql -u [username] -p [database name] < [path to file/file.sql</pre>For example, if the username is root, the database name you just created is wikidb and the path the the dumped SQL file is the Linux root home directory, type the following:<pre># mysql -u root -p wikidb < /root/Documents/wikidb.sql</pre>
# Once you have typed and entered the password, it may look like nothing is happening, be patient, it can take a while to import the database, especially if it is a large database or the computer is slow.
* Once you have typed and entered the password, it may look like nothing is happening, be patient, it can take a while to import the database, especially if it is a large database or the computer is slow.
# When the import is finished you should be returned to the console shell. You may want to use the MySQL administration program to check if the data was impoted OK.
* When the import is finished you should be returned to the console shell. You may want to use the MySQL administration program to check if the data was impoted OK.
# You database has now been imported!
* You database has now been imported!


== Troubleshooting ==
== Troubleshooting ==
Line 23: Line 23:
* '''DON'T''' forget the ; when using the MySQL administration program. If you enter a command and you get the following response:<pre>-> </pre>then you forgot the ;. To continue, type ; on it's own. Your command may then complete with a response saying it has completed. If it doesn't, type the whole command again and remember the ; !
* '''DON'T''' forget the ; when using the MySQL administration program. If you enter a command and you get the following response:<pre>-> </pre>then you forgot the ;. To continue, type ; on it's own. Your command may then complete with a response saying it has completed. If it doesn't, type the whole command again and remember the ; !


== Related articles ==
== Related Articles ==
[[Exporting a MySQL database]]
 
* [[Exporting a MySQL database]]