The MySQL database is nothing in itself. A MySQL database is a way of organizing a group of tables. and if you were going to create a bunch of different tables that shared a common theme, you would group them into one database to make the management process easier.
How can creating Your First Database?
There are most web hosts do not allowing you to creating a database directly through a PHP script. They requiring that you using the PHP/MySQL administration tools on the web hosting control panel to create these databases. After a create a database and assign a new user to this database.
For all of our beginning examples we will be using the following information:
- Server - localhost
- Database - test
- Table - example
- Username - admin
- Password - 1admin
The server is the name of the server we want to connect to. Because all of our scripts are going to be placed on the server where MySQL is located the correct address is localhost. If the MySQL server was on a different machine from where the script was running, then you would need to enter the correct url (ask your web host for specifics on this).
Your database, table, username, and password do not have to match ours. If you choose a different set of login information, remember to insert your own information when copying the scripts in this tutorial.
So far, you should have created a new database and assigned a user to it. You should not have created a table yet. If you are up-to-date, then continue the tutorial. We will be making our first table in an upcoming lesson.