We have already presented an overview of MySQL and the various data types that it supports. By now you should have enough information to sketch out a table within a database holding the information that you want to store and their associated data types. Let’s continue the process of creating a database and a user with privilege to access the database.
Most hosting plans do not automatically include root access to your account. Therefore, we will be using cPanel tools to create the database and user.
Create a MySQL Database
- Log into cPanel and locate Databases.
- Click MySQL Databases.
- In the New Database field, type a name for the database.
- Click Create Database.
- Click Go Back and the new database should appear in the Current Databases table.
- Make a note of the name of the new database that you just created.
Create a Database User
- Log into cPanel and locate Databases.
- Click MySQL Databases.
- Click Jump to MySQL Users in the top-right corner of the page.
- Under Add New User, enter a username.
- Enter a password in the password field or click the Password Generator button.
- Retype the password in the Password (Again) field.
- Click Create User.
- Make a note of the name and password of the user that you just created.
Assign Privileges to Database User
- Log into cPanel and locate Databases.
- Click MySQL Databases.
- Under Add User to Database, select the user from the User drop-down menu.
- From the Database drop-down menu, select the database you wish to allow the user access to.
- Click Add.
- From the MySQL Account Maintenance screen, select the privileges you wish to grant the user or select ALL PRIVILEGES.
- Click Make Changes.
Add your IP to Remote MySQL
- Log into cPanel and locate Databases.
- Click Remote MySQL.
- Perform a google search for “What’s my IP“
- Enter that number in the Host text box under the Add Access Host heading.
- Enter a comment that will be descriptive of the IP you are adding (e.g., home).
- Click Add Host.