How to Manage MySQL Database with phpMyAdmin

This post demonstrates how to manage a MySQL database with phpMyAdmin during PHP MySQL website development.

A database is required to store the data during website and software development. Databases are used to store users data, e.g., user registration details, orders placed on a Website, Blog Posts, Banking Transactions etc., while using websites. Most of the data that is entered or seen on a website is stored in a database.

There are various types of database software available on the market, such as MySQL, SQL Server, Oracle, etc. For web development, MySQL is preferred because it uses minimum resources (lightweight) on the server to run, has powerful features, and is best suited to the PHP language for website development. phpMyAdmin is a GUI (Graphical User Interface) tool that makes managing MySQL databases very easy and without any expert knowledge of SQL (Structured Query Language).

Here is the video to learn How to Manage MySQL Database with phpMyAdmin

Here are the steps shown in video

Step 1: Login to your web hosting cPanel account with Username & Password.

Step 2: In the DATABASES section of your cPanel account, click on the MySQL Databases link. It will display all the databases created in MySQL; e.g., in the video, WordPress is already installed in the Web Hosting account, hence it is showing WordPress Database epiz_23968433_w216. To view tables in this database, click on the Admin button under the PHPMyAdmin option of the Current Databases.

Step 3: Now in the MySQL Databases, if you want to create a new database for a new website application, provide the database name in the New Database field and click on the Create Database button. It will create a new database with the provided name under Current Databases.

Step 4: To access the newly created database, either click on the Admin button in Current Databases or go back to the cPanel and click on the phpMyAdmin link in the DATABASES section. In phpMyAdmin, click on the Connect now! button in front of the database to open the database with phpMyAdmin.

Step 5: To view the tables in the database, click on the SQL tab to open the SQL Query window, enter the “show tables” command, and click on the Go button. As shown in the video, initially you will find there are no tables in the database.

Step 6:If, by mistake, you have unselected the database, then enter the command “Use database_name” to select the working database. To create a new table in the database, click on the Structure tab, enter the table name and number of columns in the respective field, and click on the Go button.

Step 7: In the next window, provide the details of table fields, such as Column/Field Names, Data Type of Fields, Length of the Fields, Primary Key/Unique Key, Null or Not Null, Auto Increment(A_I) & Comments about table fields as shown in the video. Here, Data Type defines which type of data a table field will hold, such as int, char, varchar, etc. Length defines the size of the field. Primary Key defines that the field will be unique and will not be null or empty. Unique key defines a field that can be empty but will not store any duplicate values. Auto Increment field will automatically increment by 1 whenever a new row is inserted in the table. Comments are just some short information about the table field.

Step 8: After entering details about all the table fields, click on the Save button to create the table. Now in the Structure tab, click on the table name and enter the dummy data to test the table. Data is generally stored in website fields on the front end.

Step 9: To view the table data, click on the SQL tab and enter the required select query as shown in the video. In phpMyAdmin, table data can be viewed from the Structure tab after clicking on the table name.

Step 10: Sometimes there is a requirement for database shifting from one web hosting server to another server, such as Website Migration, Split in Database etc. To learn how to migrate a website, follow the post How to Migrate a WordPress Website to a New Host. In that case, you need to export tables or a complete database from MySQL DB. Hence, to export the complete database, click on the Export tab, select SQL format, and press the Go button. To export particular tables, choose the Custom option in the Export tab, select the tables that are needed to export with the shift or ctrl buttons of the keyboard, and press the Go button. Save the files on the hard drive.

Step 11: If there is a requirement to import a SQL backup in MySQL, then choose the database and click on the Import tab. Browse the SQL Backup file from the hard drive, select the format of the SQL Backup file, and click on the Go button. To test the successful import, click on the SQL tab and access the tables with Select queries.

This way, phpMyAdmin is very helpful in managing MySQL databases while developing PHP MySQL websites.

Thanks for visiting. For queries and suggestions, emails are welcome at learnweb@hostingcolumn.com.

Subscribe to the Hosting Column for latest updates and posts.