Tuesday, July 14, 2020

How to Interact with MySQL?



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.

phpMyAdmin

Create New User in MYSQL

Click on the “User Accounts” menu on the menu bar as shown in the image.

phpMyAdmin

Click on “Add User Account”. 

phpMyAdmin


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.

phpMyAdmin

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.

phpMyAdmin

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.

phpMyAdmin

Click on the “Go” button, on right side of the page.

On the next page fill the data as shown in the below image.

phpMyAdmin


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.

phpMyAdmin

Click on the “Edit Privileges” link. 

Click on “Databases” tab. Select the “MySchool” database and click on “Go” button 

phpMyAdmin


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.

Related Posts:

  • How to setup Database for CakePHP 4 Application?Hi guys, In the last article we have seen the strategy for CakePHP application development, till now in the series of articles we have seen the different aspects of CakePHP application development, Its installation, basic con… Read More
  • How to Interact with MySQL?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… Read More

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.