MySQL databases (cPanel)

From Email Marketing Wiki
Jump to: navigation, search
Mysql.gif
MySQL Databases is an option available in cPanel for creating MySQL databases, and assigning permissions to database users. This option is not used for adding database tables, inserting data or for querying databases; that is the realm of phpMyAdmin.

Overview

For a quick-start to creating a MySQL database, see MySQL database wizard (cPanel)

MySQL databases are often used to store and retrieve information for use on a web site, in conjunction with a server-side language such as PHP. When connecting to the database from PHP, you will need to specify a username and password. To set up the database you will need to:

  • Create a database
  • Create a database user
  • Add the user to your database

When adding the user to your database, you will also assign permissions to the user, indicating what kind of operations the user can perform.

Once this is done, you can create database tables and add data by using phpMyAdmin, or by sending SQL commands from PHP.

Create database

  • Login to Cpanel and click on the MySQL Databases button Mysql.gif (Located under the 'Databases' heading)
  • The page that loads will display several things that are of use to create and manage your database. The page will start with a short description of the MySQL Databases page.
  • The second area of use on the page is the Create New Database heading, this section is used to create your databases.

Create Newdb.png

  • Type a database name and then click on the 'Create Database' button.
  • You will get a page confirming that your database has been created

Note: Your database will not be accessible via website scripting until you add users to the database.

Modify database

The Modify Databases function can perform two important actions that are useful in keeping the databases healthy or repairing damaged databases.

Check DB: The Check DB function checks the tables in your database for errors
Repair DB: The Repair DB function attempts to repair any errors that have occurred with your database

To modify data within your database, see phpMyAdmin

Delete database

  • To delete a database, simply click the Delete Database link to the right of the database in the databases table on the MySQL Databases page

Deletedatabase.png

  • You will be asked to confirm the permanently deletion of the specified database

Confirmdelete.png

  • NOTICE: If you press 'Yes' then the database and all its data has been permanently deleted and is not recoverable

Add new database user

  • Underneath the table of databases in the MySQL Databases page is the MySQL Users section. This section manages the creation/deletion of users and the adding of users to databases.
  • Under the Add New User heading, fill out the username and password information and press the 'Create User' button

Addnewdbuser.png

  • Notice: Choosing a strong password is important to prevent your MySQL database being compromised. The 'Password Strength' indicator will show you how strong your password is.
  • Your username and password will be confirmed and the user has been added to the database.

Add user to database

  • Underneath the table of databases in the MySQL Databases page is the MySQL Users section. This section manages the creation/deletion of users and the adding of users to databases.
  • Under the Add User To Database heading, select the username and the database you wish to add that user to and press the 'Submit' button.

Addusertodb.png

  • The second page confirms the creation of the user and asks which permissions you wish to add to that users database user.

Addusertodb permissions.png

  • It is possible to add multiple users to a database to perform multiple actions. For Example: Adding 2 users, (one of which can insert and update and one which can only select) increases security as the Insert and Update permissions will only be available on pages where this action takes place so therefore hampers the efforts of hackers as there are less pages for them to use when editing the database.

Delete database user

Deleting a username link to a database

  • Under the Current Databases heading, click on the X image for the user you wish to delete from the database.

Deleteuserfromdb1.png

  • The second page will confirm your deletion

Deleteuserfromdb confirm.png

  • The user has now been removed from the database (make sure you update any webpage scripts using this username as they will no longer work)
  • The final page confirms the deletion was successful.

Deleting a username entirely

  • Underneath the table of databases in the MySQL Databases page is the MySQL Users section. This section manages the creation/deletion of users and the adding of users to databases.
  • Under the Current Users heading, click on the X image for the user you wish to delete.

Deletedatabaseuser.png

  • The second page will confirm your deletion

Deletedatabaseuser confirm.png

 Notice: Pressing 'Yes' will delete the user and any links that user has to a database. This deletion cannot be undone!

  • The final page confirms the deletion was successful.

See Also

External Links