Creating a Database in MySQL
For each MySQL database we discuss in this book, we provide a SQL script in a file with the .sql extension that sets up the database and its tables. You can execute these scripts in the MySQL command-line client tool. In the examples directory for this chapter, you’ll find the SQL script books.sql to create the books database. For the following steps, we assume that the MySQL server (mysqld-nt.exe) is still running. To execute the
1.Open a command prompt and use the cd command to change directories to the location that contains the books.sql script.
2. Start the MySQL monitor by typing
mysql -h localhost -u iw3htp4 -p
The -p option prompts you for the password for the iw3htp4 user account. When prompted, enter the password iw3htp4.
3. Execute the script by typing
This creates a books database in the server’s data directory—located on Windows at C:\Program Files\MySQL\MySQL Server 5.0\data by default.
4. Type the command
to terminate the MySQL command-line client tool. You are now ready to use your MySQL database.
Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.