Introduction: This article will guide you through the process of creating, managing, and deleting MySQL databases and users in cPanel. We will also discuss user privileges and how to connect to your database using PHP code. For additional resources, please visit our Knowledgebase at https://www.domainindia.com/login/knowledgebase.
Creating a MySQL Database in cPanel:
- Log in to your cPanel account.
- Click on "MySQL Databases" under the "Databases" section.
- In the "Create New Database" field, enter a name for your database. Note that cPanel will create the full name as "cpaneluser_databasename."
- Click the "Create Database" button.
You have now successfully created a MySQL database. Next, you will need to create a user to access the database.
Creating a User for the MySQL Database:
- In the "MySQL Databases" section, scroll down to the "MySQL Users" subsection.
- In the "Username" field, enter a username for the database user. Note that the full username will be "cpaneluser_databaseuser."
- In the "Password" field, enter a password for the database user.
- Click the "Create User" button.
You have now created a database user. To manage your database, you can use phpMyAdmin, which is available in the "Databases" section of cPanel.
Assigning User Privileges to the MySQL Database:
- In the "MySQL Databases" section, scroll down to the "Add User to Database" subsection.
- From the "User" dropdown menu, select the user you want to grant privileges to.
- From the "Database" dropdown menu, select the database you want the user to access.
- Choose the privileges you want the user to have by checking the appropriate boxes.
- Click the "Add User to Database" button.
You have now created a new database with a privileged user. You can now input this information into a PHP script or another script to access the database locally.
Deleting a MySQL Database and User:
- In the "MySQL Databases" section, locate the "Current Databases" subsection.
- Click "Delete" next to the database you want to remove.
- (Optional) If you also want to remove the user associated with the database, locate the "MySQL Users" subsection and click "Delete" next to the user.
You have now successfully deleted a MySQL Database and, optionally, its associated user.
For more information on connecting to a MySQL database using PHP code, please refer to our Knowledgebase articles:
Conclusion: Managing MySQL databases and users in cPanel is a straightforward process. By following these steps, you can create, manage, and delete databases and users with ease. Don't forget to visit Domain India's Knowledgebase for more helpful resources and guidance.