keepcalculator

06 Numbers and Powers

Create Databases in phpMyAdmin on Debian 12

Card No. 06·63835 · Updated · Standard formula, shown below

This guide walks you through creating a database in phpMyAdmin on a Debian 12 server. You’ll learn the exact clicks and settings needed, from logging in to assigning a user and privileges, so you can start building tables or connecting an application right away.

What You’ll Need

  • A Debian 12 server with phpMyAdmin already installed and accessible via a web browser (usually at http://your-server-ip/phpmyadmin).
  • The root MySQL/MariaDB password or a user account with privileges to create databases.
  • Basic familiarity with your web server (Apache or Nginx) – just for troubleshooting.

Step-by-Step

  1. Log in to phpMyAdmin. Open your browser, go to your phpMyAdmin URL, and enter your MySQL/MariaDB username (often root) and password. Click Go.
  2. Locate the Databases tab. In the top navigation bar, click Databases. This shows a list of existing databases and a form to create a new one.
  3. Enter the database name. In the Create database field, type a name that is descriptive and follows MySQL naming rules (letters, numbers, underscores; no spaces). For example, my_app_db.
  4. Choose a collation (optional). Next to the name, there is a collation dropdown. Leave it as the default (usually utf8mb4_general_ci) unless you have a specific need. This setting determines how text is sorted and compared.
  5. Click Create. The button is right below the collation dropdown. A green success message will appear, and you’ll be taken to the new database’s structure page.
  6. Add a user (if needed). For security, don’t use the root account for your application. Go to the Privileges tab (or User accounts in some versions), click Add user account, and fill in a username, host (usually localhost), and a strong password.
  7. Grant privileges. In the Database for user section, select Grant all privileges on wildcard name (user\_%) or choose Grant all privileges on database “your_db_name” to limit access to just that database. Then click Go at the bottom.
  8. Test the connection. Try logging out and logging back in with the new user, then select your database from the left sidebar. If it appears, you’re all set.

Common Mistakes

  • Using spaces or hyphens in the database name. MySQL allows them only if you quote the name every time, which causes endless headaches. Stick to letters, numbers, and underscores.
  • Forgetting to set a collation. If you skip it, the server default is used. That’s usually fine, but if you later need case-insensitive searches or special characters, you might have to convert.
  • Granting all privileges to a user on all databases. This is a security risk. Always restrict to the specific database you created.
  • Not creating a separate user. Using the root account for an application is dangerous. If the app is compromised, the attacker gets full database control.
  • Choosing the wrong host. If your app runs on the same server, use localhost. If it connects remotely, you need % or a specific IP, but that also requires firewall changes.

Tips

  • Use a descriptive name that reflects the project, like blog_2024 or inventory_system. This helps when you have many databases.
  • Always create a dedicated user with a strong password (mix of letters, numbers, symbols). Store the credentials in a secure place.
  • Back up your database regularly. In phpMyAdmin, you can use the Export tab to download a SQL dump. Do this before making major changes.
  • Learn the basics of SQL. Even with phpMyAdmin, knowing CREATE TABLE and INSERT helps you understand what the interface does.
  • Use the SQL tab for advanced operations. You can run any SQL command directly, which is useful for bulk changes or complex queries.

Troubleshooting

I get “Access denied for user” when trying to create a database. This means your current MySQL user lacks the CREATE privilege. Log in as root (or a user with global privileges) and try again. If you can’t log in as root, you may need to reset the root password via the command line.

The “Create” button does nothing. Check that the database name field isn’t empty and doesn’t contain invalid characters. Also, ensure you have JavaScript enabled in your browser; phpMyAdmin uses AJAX for some actions.

I created a database but can’t see it. Refresh the left sidebar (click the database icon at the top of the sidebar). If it still doesn’t appear, your user might not have privileges on it. Log in as root and check the privileges for that user.

Connection refused when my app tries to connect. Verify that the database user’s host matches where the app connects from. For local apps, use localhost. If the app is on another machine, you need to create a user with host % and ensure MySQL listens on the network (check bind-address in /etc/mysql/mariadb.conf.d/50-server.cnf). Also check firewalls.

phpMyAdmin shows a blank page after login. This is often a PHP error. Check the web server error log (/var/log/apache2/error.log or /var/log/nginx/error.log) for clues. Common fixes include increasing PHP memory limit or reinstalling phpMyAdmin.

Frequently Asked Questions

Can I create multiple databases at once?

No, phpMyAdmin only creates one at a time. You can repeat the process, but it’s often easier to use a SQL script with multiple CREATE DATABASE statements.

What is the default collation I should choose?

For most new projects, utf8mb4_general_ci is a safe choice. It supports all Unicode characters and is fast. If you need case-sensitive comparisons, pick utf8mb4_bin.

How do I delete a database?

Go to the Databases tab, check the box next to the database name, and click Drop. Be absolutely sure, because this deletes all tables and data permanently.

Can I rename a database?

phpMyAdmin doesn’t have a direct rename option. The safest method is to export the database, create a new one with the desired name, and import the SQL dump. Then delete the old one.

How do I give another user access to my database?

Go to the Privileges tab, click Add user account, create the user, and in the “Database for user” section, select your database and grant the needed privileges. You can also edit an existing user from the User accounts page.

What if I forget the root password?

You can reset it from the command line. Stop the MySQL service, start it in safe mode (mysqld_safe --skip-grant-tables), log in without a password, and update the root password with an SQL command. Then restart the service normally.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →