1 / 39

COMP4332/RMBI4310

COMP4332/RMBI4310. How to Use MySQL. Prepared by Raymond Wong Presented by Raymond Wong. You have already installed MySQL successfully. The installation guideline of the tutorial webpage shows some steps of how to use MySQL (i.e., the last few steps)

ellamae
Download Presentation

COMP4332/RMBI4310

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMP4332/RMBI4310 How to Use MySQL Prepared by Raymond Wong Presented by Raymond Wong

  2. You have already installed MySQL successfully. • The installation guideline of the tutorial webpage shows some steps of how to use MySQL (i.e., the last few steps) • For clarity, let us illustrate how to use MySQL in this set of lecture notes.

  3. Before that, you need to understand the following concepts • Server • Client

  4. mysqld mysql DatabaseServer DatabaseClient connect success

  5. mysqld mysql DatabaseServer DatabaseClient SQL Statement Result of SQL

  6. mysqld mysql A “.sql” file containing SQL Statement DatabaseServer DatabaseClient Result of SQL

  7. Note that “server” and “client” are two concepts. • Usually, a server is a machine and a client is another machine. • However, in some cases (e.g., development), both the server and the client could be in the same machine.

  8. Next, we will illustrate how to use MySQL in “Windows”. • Similar steps could be applied to other operating systems (e.g., Mac and linux) • Please see the tutorial webpage (near to the end of the steps of the installation guideline)

  9. In this example, we assume that you have database called “university”. • Besides, in this database, you also have the table “student”. • After “reading” this set of lecture notes, you should know how to use MySQL. • After that, you could create your own database and create your own table by following the commands shown on the course webpage.

  10. Click the “Start” menu.

  11. Type “cmd” and press <enter>

  12. A command prompt is shown.

  13. Click the “Start” menu.

  14. Type “cmd” and press <enter>

  15. The “second” command prompt is shown.

  16. Re-adjust/re-position these two command prompts

  17. Type “mysqld --console” in the left command prompt and press <enter>

  18. Some messages are shown. Those messages are related to the messages when we start the database server. Focus on the right command prompt. This is used for the database client.

  19. Type “m:” and press <enter>

  20. Type “cd M:\Course\4332\2018\Notes\Program\MySQL” and press <enter>

  21. Show the content of “TestQuery.sql” Type “type TestQuery.sql” and press <enter> use university; select * from student;

  22. Type “mysql –u root -p” and press <enter>

  23. This TEXT message is shown and it asks us to enter our password of the database server (set up in the installation) .

  24. Enter our password of the database server (set up in the installation) and press <enter>

  25. We could connect the database server successfully. The “MySQL” welcome prompt is shown.

  26. Type “use university;” and press <enter>

  27. A prompt “Database changed” is shown.

  28. Type “select * from student;” and press <enter> The following prompt is shown.

  29. Type “source TestQuery.sql” and press <enter> The following prompt is shown.

  30. Type “exit” and press <enter> The following prompt is shown.

  31. We have just quitted the “database client”. • The next few slides show how we could quit the “database server”.

  32. Focus on the “left” command prompt.This is for the database server. Then, press “<Ctrl> C”.

  33. We “quitted” the “database server” and returned back to the command prompt.

  34. After you see a set of screenshots, you should know how to use MySQL • The remaining issue is how to “edit” and “open” the SQL script file (e.g., “TestQuery.sql”)

  35. You could use any TEXT editor (e.g., notepad) to edit and open the SQL script file. • However, a “normal” editor (e.g., notepad) does not show the “color” for the syntax of SQL.

  36. If you want to have some editors with “colorful” syntax, you could consider the following. • MySQL Workbench (in "MySQL Community Edition")(particularly for writing MySQL statements) • Code Writer (in Windows)(in general for many programming languages including HTML, JavaScript, JSON, C#, VB, C++, ASP, PHP, Perl, Python, Ruby, SQL and MongoDB) • Sublime Text (in Windows, Mac and Linux)(in general for many programming languages including HTML, JavaScript, JSON, C#, C++, ASP, PHP, Perl, Python, Ruby, SQL and MongoDB) Recommendation: Sublime Text

  37. Sublime Text

  38. About SQL Statement stored in a File • We know that we could type “source TestQuery.sql” in the MySQL command prompt to execute the SQL statement stored in the file “TestQuery.sql”. • Alternatively, we could open file “TestQuery.sql” in a TEXT editor (e.g., sublime text) and then could “copy-and-paste” the content of this file to the MySQL command prompt to execute the SQL statement (stored in the file)

More Related