How to create a MySQL/MariaDB database and user¶
Before you can use your AppGini-generated web database application, you need to have a MySQL or MariaDB database and a user with permissions to access and modify the database.
Sometimes, your hosting provider will create the database and user for you. In this case, you'll usually receive an email with the database details. But in most cases, you'll need to create the database and user yourself.
Creating a database and user using cPanel¶
Most shared hosting providers offer cPanel, a web-based control panel that makes it easy to manage your hosting account. Here are the general steps to create a database and user using cPanel:
- Log in to your cPanel account.
- Look for a section named 'Databases' and click on 'MySQL Databases'.
- In the 'Create New Database' section, enter a name for your database and click 'Create Database'.
You should specify a name that is relevant to your application, as you might have multiple databases
on your hosting account. So, it would be easier to identify the database later on.
- After creating the database, scroll down to the 'Add New User' section.
- Enter a username and password for the new user and click 'Create User'.
Make sure to use a strong password. You can use the 'Password Generator' tool to create a strong password.Please take note of the database name, username, and password you've just created. You'll need them when setting up your AppGini-generated web database application.
- After creating the user, scroll down to the 'Add User to Database' section.
- Select the user you created from the 'User' dropdown and the database you created from the 'Database' dropdown.
- Click 'Add'.
- On the next screen, select 'All Privileges' and click 'Make Changes'.
Selecting 'All Privileges' will give the user full access to the database. This is needed for your AppGini-generated application to be able to create tables and manage data. But if your database schema has already been created and you don't plan to modify it, you can uncheck the 'Create', 'Alter', and 'Drop' privileges.
That's it! You've successfully created a database and user for your AppGini-generated web database application. The next step is to set up your AppGini-generated application
If your hosting provider provides another control panel, like Plesk, the steps might be slightly different but the general idea is the same. You can refer to your hosting provider's documentation for more details.
Creating a database and user using phpMyAdmin¶
Your hosting provider might offer phpMyAdmin, a web-based tool that allows you to manage MySQL databases. You can create a database and user using phpMyAdmin as follows:
- Log in to your phpMyAdmin account.
- Click on the 'Databases' tab.
- Enter a name for your database in the 'Create database' field and click 'Create'.
- Click on the 'Privileges' tab.
- Click 'Add user account'.
- Enter a username and password for the new user.
- In the 'Database for user account' section, select the database you created.
- Click 'Go'.
- On the next screen, select 'All Privileges' and click 'Go'.
Selecting 'All Privileges' will give the user full access to the database. This is needed for your AppGini-generated application to be able to create tables and manage data. But if your database schema has already been created and you don't plan to modify it, you can uncheck the 'Create', 'Alter', and 'Drop' privileges.
That's it! You've successfully created a database and user for your AppGini-generated web database application. The next step is to set up your AppGini-generated application
Creating a database and user using the command line¶
If you have SSH access to your server, you can create a database and user using the command line. Here are the general steps:
- Log in to your server using SSH.
- Connect to MySQL using the following command: If the above command results in an error, you might need to specify the MySQL root password: Then enter the MySQL root password when prompted.
- Create a new database using the following command:
Replace
dbname
with the name you want to give to your database. - Create a new user using the following command:
Replace
username
with the username you want to give to your user andpassword
with the password you want to set. Make sure to use a strong password. - Grant the user full access to the database using the following command:
Replace
dbname
with the name of the database you created andusername
with the username you created. - Flush the privileges using the following command:
That's it! You've successfully created a database and user for your AppGini-generated web database application. The next step is to set up your AppGini-generated application