Perl Programming Page 2 - Creating a Database with Perl and DBI |
TheDESCRIBEcommand shows all the fields in the table and their types. This will show us if themusicianstable was created correctly: mysql> DESCRIBE musicians;
3 rows in set (0.00 sec) This looks OK so far. Let’s create the other two tables:what_they_playandinstruments: mysql> CREATE what_they_play ( mysql> CREATE TABLE instruments ( Creating a Non-root User with the GRANT Command It is important to create a non-root user to access the database—performing normal non-MySQL-admin activities using the root user is a bad idea for security reasons. So let’s create a user that will be allowed to perform basic queries on themusicians_dbdatabase: mysql> GRANT SELECT, INSERT, UPDATE, DELETE You can trust us when we say that this command creates a user namedmusicfan with a password “CrimsonKing”5 and grants this user permission to select, insert, update, and delete records from the database. Or, you can check out the documentation and read all about theGRANTcommand. We are going to start inserting data into ourmusicians_dbdatabase, so we need to log out as therootuser and log back into MySQL as the newly createdmusicfanuser: mysql> quit mysql>
blog comments powered by Disqus |