Welcome, in our last article we have seen that CakePHP 4.0 application is up and running, but it was not able to connect to the database. The reason behind this is that we have not yet created any database. To make connection with database it is good idea to learn some basics about MySQL before proceeding further in CakePHP 4.0 application development.
phpMyAdmin
phpMyAdmin is PHP based MySQL administration tool, it is free and by default installed with XAMPP control panel. There are many free and paid tools for MySQL administration but for the learning and development purpose phpMyAdmin is more than enough.
Let’s start phpMyAdmin, go to your windows start menu and start the XAMPP control panel. Start the Apache service and MySQL service. When both services are up and running, jump to web browser and type “localhost/phpMyAdmin”. It will start the application and you will see the page like below.
Create New User in MYSQL
Click on the “User Accounts” menu on the menu bar as shown in the image.
Click on “Add User Account”.
On the Login information form enter the login information in “User Name” and in “Password” text boxes, type the same password again in the “Re-Type” text box.
Click on the “Go” button given on the extreme right bottom of the page. If not visible scroll down the page.
At this stage a new database user is created. Till now we have not assigned any privileges to this user. We will do this later in the article.
Create New Database
Click on the “Databases” menu.
Enter the database name in the text box, as I entered “MySchool”, you can enter name of your database.
Next click on the “Create” button. It will create the new database and will lead you to new page for New Table creation.
Create a New Table in Database
1) Enter the table name “Students” in the name field. You can enter your table name. in the number of column text box enter the count of your table columns in my case I have entered 3.
Click on the “Go” button, on right side of the page.
On the next page fill the data as shown in the below image.
Click on the “Save” button in the right bottom of form. it will create the new table.
Assign Privileges to User
Go to “User Accounts” page.
Select the Used “DBAdmin” by checking the checkbox in my case.
Click on the “Edit Privileges” link.
Click on “Databases” tab. Select the “MySchool” database and click on “Go” button
Now the database is selected for privileges. Click on “Go” button.
At this stage we have created a new user, created a new database, created a new table and assigned the privileges to the newly created user for the newly created database.
Stay tuned with us, in the next article we will move back to CakePHP and connect our application to this database.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.