Problem:
How do I create an empty MySQL Database?
Solution:
Databases offer a method for managing large amounts of information easily over the web. They are necessary to run many web-based applications such as bulletin boards, content management systems, and online retail shops.To create a database from the MySQL Databases Icon.
Create a Database User
- Log into the cPanel
- Click the MySQL Databases icon under the "Databases" category
- In the New Database field, type a name for the database.
- Click Create Database.
- Click Go Back.
- The new database will appear in the Current Databases table.
After creating the database, a user will need to be created and their privileges added to the newly created database. Please note that MySQL user accounts must be created separately from mail and web administrator accounts.
To create a new user account:
Define a User's Privileges
- To quickly access the MySQL Users interface, click Jump to MySQL Users.
- Under Add New User, enter a username.
- Note: The username must be 7 letters or shorter.
- Enter a password in the Password field.
- For help generating a strong password, click the Generate Password button.
- Retype the password in the Password (Again) field.
- Click Create User.
Privileges define how the user is able to interact with the database. For example, they will determine whether or not the user can add and delete information.
To define a user’s privileges:
After doing all these steps, create the database's tables either via phpMyAdmin, MySQL software or use an online PHP or Perl script.
- Under Add User to Database, select a user from the User drop-down menu.
- From the Database drop-down menu, select the database to which you wish to allow the user access.
- Click Add.
- From the MySQL Account Maintenance screen, select the privileges you wish to grant the user, or select ALL PRIVILEGES.
- Click Make Changes.
The username format will be: username_dbuser
The database format will be: username_dbname
The hostaddress will be: localhostFor example, enter the following variables:
dbusername: admin
the following format is placed in the connection string
dbname: db01
password: passwordHostname: localhost
Note: The password remains the same format.
dataName: username_db01
dataUser: username_admin
Password: passwordThe connection string can be either of any examples below:
For example, we will use the above example variables in a connection string:
For Perl:
$dbh = DBI->connect("DBI:mysql:username_db01:localhost","username_admin","password");For PHP:
$dbh=mysql_connect ("localhost", "username_admin", "password")For more information on how to work with phpMyAdmin. please visit: phpMyAdmin.net.
or die ('I cannot connect to the database.');
mysql_select_db ("username_db01");