๐Ÿ—„๏ธ

Databases

10 articles Allan Tanaka By Allan Tanaka

Create and manage MySQL databases and phpMyAdmin.

How to Create a MySQL Database and User in Plesk

Plesk makes it easy to create MySQL databases and database users for your website or application. This guide covers creating databases, setting up database users, and managing access permissions. Creating a Database 1. Log in to Plesk. 2. Go to Databases in the left navigation menu. 3. Click Add Database. 4. Fill in the required fields: - Database name: Enter a name for the database (e.g., mywebsite_db). A prefix will be added automatically. - Related site: Select the domain this database is associated with (optional but recommended). - Database server: Select the database server (usually MySQL or localhost). - Database user: Create a new user for this database. Enter a username and a strong password. - Access control: Choose whether this user can access all databases on the account or only this specific database. - Character set: Select UTF-8 (utf8mb4) unless your application requires a different character set. 5. Click OK to create the database and user. Adding a User to an Existing Database 1. Go to Databases. 2. Click the database name you want to modify. 3. Go to the Users tab. 4. Click Add Database User. 5. Enter the username and password. 6. Click OK. Viewing Database Connection Details 1. Go to Databases. 2. Click the database name. 3. Click Connection Info. 4. You will see: - Host: The database server address (usually localhost). - Port: The MySQL port (usually 3306). - Database name: The full database name (including prefix). - Username: The full database username (including prefix). Important Notes - Plesk automatically adds a prefix to database names and usernames (based on your account). - The number of databases you can create may be limited by your hosting plan. - Always use utf8mb4 character set for modern applications to support all characters including emojis. Troubleshooting "Cannot create database โ€” limit reached": - Contact your hosting provider to increase your database limit or upgrade your plan. Application cannot connect to the database: - Verify the connection details in Databases โ†’ Connection Info. - Ensure the database user has access to the correct database.

How to Access phpMyAdmin in Plesk

phpMyAdmin is a web-based tool for managing MySQL databases. You can use it to create tables, run SQL queries, import and export data, and manage database users. This guide covers how to access and use phpMyAdmin in Plesk. Accessing phpMyAdmin 1. Log in to Plesk. 2. Go to Databases. 3. Click the database you want to manage. 4. Click Webadmin (or phpMyAdmin). 5. phpMyAdmin will open in a new tab, logged in with the database user credentials. Accessing phpMyAdmin for All Databases 1. Go to Databases. 2. At the top of the page, click the phpMyAdmin icon (or link). 3. This opens phpMyAdmin with access to all databases on your account. Common phpMyAdmin Operations - Browse tables: Click a database in the left sidebar, then click a table to view its contents. - Run SQL queries: Click the SQL tab, enter your query, and click Go. - Import data: Click Import, select a .sql file, and click Go. - Export data: Click Export, choose Quick or Custom, and click Go to download. - Create a table: Click a database, enter a table name and number of columns, and click Go. - Repair a table: Click a table, go to the Operations tab, and click Repair table. - Optimize a table: Click a table, go to Operations, and click Optimize table. Important Notes - When you open phpMyAdmin from Plesk, it automatically logs you in โ€” no manual login required. - Be cautious when running SQL queries โ€” a mistake can permanently modify or delete data. - Always back up your database before making changes. Troubleshooting phpMyAdmin link is missing: - Contact your hosting provider โ€” phpMyAdmin may not be installed or enabled. "Access denied" in phpMyAdmin: - Try accessing it again from Databases in Plesk to refresh the login session.

How to Import and Export Databases in Plesk

Importing and exporting databases is essential for migrating websites, restoring data, and creating backups. This guide covers importing and exporting MySQL databases using phpMyAdmin in Plesk. Importing a Database via phpMyAdmin 1. Log in to Plesk. 2. Go to Databases. 3. Click the database you want to import data into. 4. Click Webadmin (phpMyAdmin). 5. Click the Import tab. 6. Click Choose File and select your .sql or .sql.gz backup file. 7. Under Format, ensure SQL is selected. 8. Click Go to start the import. 9. Wait for the import to complete. A success message will appear. Exporting a Database via phpMyAdmin 1. In Plesk, go to Databases. 2. Click the database you want to export. 3. Click Webadmin (phpMyAdmin). 4. Click the Export tab. 5. Select Quick for a standard export, or Custom for more options (selecting specific tables, adding compression). 6. Under Format, select SQL. 7. Click Go. The database backup will be downloaded to your computer. Importing a Database Using the Plesk Dump Tool 1. In Plesk, go to Databases. 2. Click the database name. 3. Click Import Dump. 4. Upload a .sql dump file from your computer. 5. Click OK to import. Important Notes - Importing a database will overwrite existing tables with the same names. - phpMyAdmin has an upload limit (typically 50 MB or higher). For larger databases, contact your hosting provider about importing via SSH. - Always export a backup before importing new data. - When migrating a database, ensure the character set matches (use utf8mb4 for modern applications). Troubleshooting "File too large" error during import: - Compress the SQL file to .sql.gz before importing. - Split the file into smaller chunks. - Contact your hosting provider to increase the upload limit. "SQL query error" during import: - The SQL file may contain syntax errors or may be from a different MySQL version. - Check the error message in phpMyAdmin for details.

How to Change a Database User Password in Plesk

If you need to update the password for a database user (for security reasons, or if the password has been compromised), you can do this directly from the Plesk interface. Changing a Database User Password 1. Log in to Plesk. 2. Go to Databases. 3. Click the database name the user is associated with. 4. Go to the Users tab. 5. Click the username of the user you want to modify. 6. Enter the new password in the New password field. 7. Click OK to save. Important Notes - After changing the password, you will need to update it in your application configuration file (e.g., wp-config.php for WordPress). - If your application cannot connect to the database after a password change, verify the configuration file has been updated. Troubleshooting Application shows "Error establishing a database connection" after password change: - Update the database password in your application configuration file. - Verify the username is correct.

How to Delete a Database in Plesk

If you no longer need a database, you can remove it from Plesk. Deleting a database permanently removes all tables and data. This guide covers how to safely delete databases. Deleting a Database Warning: This action is permanent and cannot be undone. Always export a backup before deleting. 1. Log in to Plesk. 2. Go to Databases. 3. Select the checkbox next to the database you want to delete. 4. Click Remove. 5. Confirm the deletion. The database, all its tables, and associated database users will be permanently removed. Important Notes - Deleting a database will break any website or application that relies on it. - Always export a backup before deleting a database. - The database users associated with the database may also be removed. Troubleshooting Cannot delete a database: - The database may be in use. Contact your hosting provider for assistance. Website shows database errors after deletion: - Restore the database from a backup, or reconfigure the application to use a different database.

How to Create a Database Backup in Plesk

Plesk gives you two ways to back up a database โ€” the built-in Export Dump tool or phpMyAdmin. Both produce a downloadable SQL file you can use to restore your data later. Method 1: using the Export Dump tool 1. Log in to your Plesk control panel. 2. Go to Websites & Domains > Databases. 3. Find the database you want to back up. 4. Click Export Dump next to the database name. 5. Choose where to save the dump file on the server (the default root directory is fine). 6. Tick Automatically download dump after creation if you want a local copy on your computer. 7. Click OK. 8. Once the export finishes, you'll see a confirmation with a download link at the bottom right of the page. The exported file is saved as a .zip archive containing the SQL dump. Method 2: using phpMyAdmin 1. Go to Websites & Domains > Databases. 2. Click phpMyAdmin next to your database. This opens phpMyAdmin and logs you in automatically. 3. Click the Export tab at the top. 4. For a quick backup: leave the method as Quick and format as SQL, then click Go. 5. For a compressed backup: choose Custom, scroll down to Compression, select zipped or gzipped, then click Go. Important notes - Always download a copy of your backup to your local computer โ€” don't rely only on server-stored copies. - Never save exports to a web-accessible directory like httpdocs. Anyone could download your database. - For large databases, use the compressed export option in phpMyAdmin to reduce file size and download time. - Schedule regular backups before making changes to your website or updating CMS software. Restoring from a backup To restore, go to Databases and click Import Dump. Upload your SQL or ZIP file and click OK. If the database doesn't exist yet, tick Create a new database during import. Troubleshooting - Export Dump button missing? Your database might not have a user account assigned. Go to User Management, create a new database user linked to that database, then try again. - phpMyAdmin times out on large databases? Use the Export Dump method instead โ€” it handles large databases more reliably. - Import fails with errors? Make sure you're importing into the same database type (e.g., MySQL dump into a MySQL database).

How to Check and Repair Database Tables in Plesk

Database tables can become corrupted after a server crash, unexpected shutdown, or disk issue. Plesk has a built-in tool to check and repair MySQL/MariaDB tables without needing command-line access. Using the built-in Check and Repair tool 1. Log in to your Plesk control panel. 2. Go to Websites & Domains > Databases. 3. Find the database you want to check. 4. Click Check and Repair in the database tools area. 5. Plesk will scan all tables. If everything is fine, you'll see a confirmation that no problems were found. 6. If problems are found, click See Details and Resolve. 7. You'll see a list of affected tables. Select the tables you want to fix. 8. Click Repair Selected. Plesk uses the mysqlcheck utility behind the scenes, so this is the same as running a repair from the command line. Using phpMyAdmin If you prefer more control, you can check and repair tables through phpMyAdmin: 1. Go to Websites & Domains > Databases. 2. Click phpMyAdmin next to your database. 3. Select your database from the left sidebar. 4. At the bottom of the table list, click Check All to select every table. 5. From the With selected dropdown, choose Check table and click Go. 6. Review the results โ€” look for any status other than OK. 7. To repair: select the problem tables (or all), choose Repair table from the dropdown, and click Go. Important notes - Back up your database first. Always export a dump before running repairs โ€” a repair on a severely damaged table could result in data loss. - The Check and Repair tool works with MySQL and MariaDB databases. InnoDB tables may report as "doesn't support repair" โ€” this is normal, as InnoDB has its own crash recovery. - If you see "Table is marked as crashed and should be repaired" errors on your website, this tool is exactly what you need. Troubleshooting - Repair says OK but site still has errors? The issue may be with your application code or configuration, not the database tables. Check your CMS error logs. - Table won't repair? Severely corrupted tables may need to be restored from a backup. Export what you can, drop the table, and import your backup. - Check and Repair option missing? This tool only appears for MySQL/MariaDB databases. PostgreSQL databases use different repair methods.

How to Create a Limited Database User in Plesk

By default, Plesk creates database users with full Read and Write access. If you need a user with limited permissions โ€” for example, read-only access for a reporting tool or write-only for a data import script โ€” you can customise their privileges. Creating a new database user 1. Log in to your Plesk control panel. 2. Go to Websites & Domains > Databases. 3. Click the User Management tab. 4. Click Add New Database User. 5. Enter a username and a strong password. 6. Select the database this user should have access to (or choose Any for a universal user). 7. Under Role, choose one of the predefined options: - Read and Write โ€” full access (default) - Read Only โ€” can view data but not change it - Write Only โ€” can insert/update/delete but not read 8. Click OK to create the user. Setting custom privileges If the predefined roles don't fit your needs, you can create a custom set of privileges: 1. Go to Databases > User Management. 2. Click on an existing user's name (or create a new one first). 3. Under Role, you'll see the current role and checkboxes for individual privileges. 4. Select or clear specific privileges as needed: - Select โ€” read data from tables - Insert โ€” add new rows - Update โ€” modify existing data - Delete โ€” remove rows - Create โ€” create new tables - Drop โ€” delete tables - Alter โ€” change table structure - Index โ€” manage indexes - Create Temporary Tables โ€” create temp tables - Lock Tables โ€” lock tables during operations - Create View / Show View โ€” manage database views 5. Once you change any privilege, the role automatically switches to Custom. 6. Click OK to save. Common use cases - Reporting/analytics tool: grant only Select and Show View. - Data import script: grant Select, Insert, Create, and Create Temporary Tables. - Application user: grant Select, Insert, Update, Delete โ€” but not Drop or Alter for safety. Important notes - Passwords must be at least 5 characters and cannot contain the username. - Each user account can only access the specific database it's assigned to, unless created as a universal user. - Custom privilege changes only apply to MySQL/MariaDB databases. - Your hosting provider may restrict certain privileges. If a privilege checkbox is missing, it's been disabled at the server level. Troubleshooting - User can't connect? Double-check the password and make sure the correct database is selected. - Application errors after restricting privileges? The app likely needs more permissions than you've granted. Check the app's documentation for required database privileges. - Can't see the privilege checkboxes? This feature is only available for MySQL/MariaDB. SQL Server users can only use the predefined roles.

How to Allow Remote Database Connections in Plesk

By default, databases in Plesk only accept connections from the server itself (localhost). If you need to connect from an external application, a local development tool like MySQL Workbench, or another server, you'll need to enable remote access. Step 1: enable remote access for the database user 1. Log in to your Plesk control panel. 2. Go to Websites & Domains > Databases. 3. Click the User Management tab. 4. Click the name of the database user you want to grant remote access to. 5. Under Access control, choose one of these options: - Allow local connections only โ€” default, no remote access - Allow remote connections from any host โ€” lets anyone connect (use with caution) - Allow remote connections from โ€” restricts access to specific IP addresses or hostnames (recommended) 6. Click OK to save. Step 2: connect from your remote application Use these connection details in your external application or tool: - Host: your domain name or server IP address - Port: 3306 (default MySQL/MariaDB port) - Username: the database user you configured above - Password: the database user's password - Database: the name of your database Important notes - Security first: avoid "Allow remote connections from any host" whenever possible. Specify the exact IP address of the server or computer that needs access. - Firewall: port 3306 must be open on your server's firewall. If connections time out, ask your hosting provider to check the firewall rules. - Encrypted connections: remote MySQL connections are unencrypted by default. For sensitive data, configure SSL for your database connections. - This setting is per-user โ€” each database user has their own access control settings. - If you no longer need remote access, switch back to Allow local connections only to reduce your attack surface. Testing the connection From your local computer (if you have MySQL client installed), run: mysql -u your_db_user -p -h yourdomain.com Or use a GUI tool like MySQL Workbench, DBeaver, or HeidiSQL โ€” enter the connection details above and click Test Connection. Troubleshooting - Connection refused? The server firewall is likely blocking port 3306. Contact your hosting provider to open it. - Access denied? Make sure the remote access setting is correct for that specific user, and double-check the password. - Connection times out? This usually means port 3306 is blocked. Try a different network to rule out your local firewall. - Access control option not showing? Your hosting plan may not include the Remote access for database users permission. Contact your hosting provider.

How to View Database Size and Usage Statistics in Plesk

Keeping an eye on your database size helps you manage disk space and catch bloated tables before they cause performance issues. Plesk gives you several ways to check how much space your databases are using. Method 1: check from the Statistics page 1. Log in to your Plesk control panel. 2. Click Statistics in the left sidebar. 3. Look at the Disk space usage by services chart. It shows a breakdown of space used by website files, emails, databases, logs, and backups. 4. The Databases portion shows the total size of all your databases combined. This gives you a quick overview but doesn't show individual database sizes. Method 2: check from the Databases page 1. Go to Websites & Domains > Databases. 2. You'll see a list of all databases for your subscription. 3. Each database entry shows its type (MySQL/MariaDB), the related website, and basic info. 4. Note: Plesk may not display the exact size on this page for all configurations. For precise numbers, use phpMyAdmin (see below). Method 3: check detailed table sizes in phpMyAdmin 1. Go to Websites & Domains > Databases. 2. Click phpMyAdmin next to the database you want to inspect. 3. Click your database name in the left sidebar. 4. At the bottom of the table list, you'll see a size total for the database. 5. Each table row shows its own Size column โ€” this helps you identify which tables are using the most space. 6. For more detail, click a table name and then the Operations tab to see data length, index length, and overhead. Understanding the numbers - Data length: the actual space used by your data. - Index length: space used by indexes (speeds up queries). - Overhead: wasted space from deleted rows. You can reclaim this by running Optimize table from the dropdown in phpMyAdmin. Important notes - Plesk calculates disk usage once per day during the daily maintenance task. The Statistics page may not reflect changes made in the last 24 hours. - For real-time size information, always use phpMyAdmin. - Database size counts toward your hosting plan's disk space quota. - Large tables with lots of overhead can be optimised to free up space โ€” select the table in phpMyAdmin, choose Optimize table from the With selected dropdown. Troubleshooting - Statistics page shows 0 for databases? The daily maintenance task may not have run yet. Wait 24 hours or ask your hosting provider to trigger it manually. - Database seems too large? Check for log tables, session tables, or spam data that can be safely cleaned up. Many CMS platforms store revision history and transient data that grows over time. - Can't access phpMyAdmin? Make sure your database has at least one user account assigned. Go to User Management and create one if needed.