Tag Archives: MySQL

How To Repair MySQL Database?

A MySQL database is a relational database management system (RDBMS) that utilizes structured query language (SQL) to store, retrieve, and manage structured data.

MySQL databases consist of tables organized into rows and columns, with each table representing a specific data entity and each row representing a single record or entry. MySQL is widely used for web applications and websites, offering features such as data integrity, transaction support, scalability, and robust security mechanisms.

It is an open-source database system, making it accessible and customizable for a wide range of applications and industries. MySQL is known for its reliability, performance, and ease of use, making it a popular choice for developers and businesses seeking a powerful and cost-effective solution for managing their data.

Repairing a MySQL database involves several steps to identify and fix any issues that may be causing corruption or damage to the database. But to fix a database you need to access it. To access a MySQL database on cPanel, you typically follow these steps:

  1. Log in to cPanel: Open your web browser and navigate to your cPanel login page. This is usually accessed by appending “/cpanel” to your domain name (e.g., yourdomain.com/cpanel). Enter your cPanel username and password to log in. If this doesn’t works, then alternatively you can access the cPanel from your hosting’s account page.
  2. Locate the MySQL Databases Icon: Once logged in, you’ll see a variety of icons representing different features and functions available in cPanel. Look for the “MySQL Databases” or “Databases” icon, which is usually located under the “Databases” section.
  3. Access MySQL Databases: Click on the “MySQL Databases” icon to access the MySQL Databases interface. This interface allows you to manage your MySQL databases, including creating new databases, adding users, and assigning privileges.
  4. Locate Your Database: In the MySQL Databases interface, you’ll see a list of existing databases under the “Current Databases” section. Each database will have a name preceded by your cPanel username and an underscore (e.g., username_database1). Locate the database you want to access.
  5. Access phpMyAdmin: To interact directly with your MySQL database, click on the “phpMyAdmin” icon, which is usually located next to the database name. phpMyAdmin is a web-based application that provides a graphical user interface for managing MySQL databases.
  6. Log in to phpMyAdmin: After clicking on the phpMyAdmin icon, you’ll be directed to the phpMyAdmin login page. Enter the username and password for the MySQL database user associated with the database you want to access. This may be different from your cPanel login credentials.
  7. Navigate Your Database: Once logged in to phpMyAdmin, you’ll see a list of databases on the left-hand side of the screen. Click on the name of the database you want to access to expand it and view its tables. You can then click on individual tables to view and manage their contents.
  8. Perform Database Operations: From the phpMyAdmin interface, you can perform various database operations, such as running SQL queries, creating or modifying tables, importing or exporting data, and managing users and permissions.
  9. Log Out and Close phpMyAdmin: After you’ve finished working with your database, be sure to log out of phpMyAdmin to secure your data. You can do this by clicking the “Log Out” button in the phpMyAdmin interface. Once logged out, you can close the phpMyAdmin window or tab.

By following these steps, you can easily access and manage your MySQL databases on cPanel using phpMyAdmin.

Here’s a general guide on how to repair a MySQL database:

Backup Your Database: Before making any changes to your database, it’s essential to create a backup to ensure that you can restore your data in case anything goes wrong during the repair process. You can use MySQL’s built-in tools or third-party backup solutions to create a backup of your database.

Identify Database Issues: Use MySQL’s diagnostic tools to identify any issues or errors in your database. You can check the MySQL error log, run diagnostic queries, or use tools like MySQL Workbench to analyze the database’s structure and integrity.

Use MySQL Check Table Command: MySQL provides a built-in command called CHECK TABLE that allows you to check the integrity of tables in your database and repair any corruption or damage. You can use this command to check individual tables or the entire database.

CHECK TABLE table_name;

Use MySQL Repair Table Command: If the CHECK TABLE command identifies any issues with your tables, you can use the REPAIR TABLE command to fix them. This command repairs corrupted tables by rebuilding the table’s indexes and data structure.

REPAIR TABLE table_name;

Use MySQL Repair Database Command: If you suspect that your entire database is corrupted, you can use the REPAIR DATABASE command to repair all tables in the database at once.

REPAIR DATABASE database_name;

Use MySQL Table Maintenance Operations: MySQL provides additional table maintenance operations, such as OPTIMIZE TABLE and ANALYZE TABLE, which can help improve the performance and integrity of your database. You can use these commands periodically to optimize and maintain your database.

OPTIMIZE TABLE table_name;

ANALYZE TABLE table_name;

Monitor Repair Progress and Errors: During the repair process, monitor the progress and check for any errors or warnings that may occur. This will help you ensure that the repair is successful and that no further issues arise.

Verify Database Integrity: After repairing your database, verify its integrity by running diagnostic queries and checking for any remaining issues. Ensure that your data is intact and that the database functions properly.

Regular Maintenance and Monitoring: To prevent future database issues, implement regular maintenance tasks such as backups, monitoring, and optimization. Regularly check for errors, monitor database performance, and address any issues promptly to keep your MySQL database healthy and reliable.

By following these steps and best practices, you can repair your MySQL database and ensure that it remains stable, reliable, and free from corruption or damage.

Configuring MySQL Repository On Linux Server CentOS

CentOS offers you no native MySQL package so you need to add it on your own. This you can do by adding a MySQL hosted repository on your Linux System CentOS.

Add the MySQL Yum repository to your system’s repository list. This can be done by installing an RPM that comes with MySQL.

  1. Go to the Download MySQL Yum Repository page (https://dev.mysql.com/downloads/repo/yum/) in the MySQL Developer Zone
  2. Select and download the release package for your platform
  3. Use the yum package manager to install MySQL (yum -y install mysql-server)
  4. Enable the MySQL Daemon Service, use these commands systemctl start mysql followed by systemctl enable mysql

That’s it. Now you may check and make sure that MySQL is up and running, simply use this command – sudo service mysqld status.

Importing MySQL Databases Via SSH Command Line On Self Managed Servers

SANGKRIT.net not only offers you Managed and Fully Managed servers but it also lets you subscribe self-managed server option which is only recommended for command line experts. Because self-managed servers are without a control panel such as cPanel, Plesk, or Simple Control Panel.

These self-managed servers do not have phpMyAdmin installed which is used for managing MySQL databases. So in order to manage databases, you are required to use the SSH command line to import .SQL backup files.

This post guides you through importing MySQL databases via SSH.

Continue reading Importing MySQL Databases Via SSH Command Line On Self Managed Servers

What Is Increased Time To 1st Byte? How It Affects Your Website’s Speed?

An increased time to 1st byte means your website is running too many SQL queries or non-optimized SQL queries which can also include server-side calls to third-party APIs.

If you’re a WordPress user, there are a number of plugins you can check out to decrease the number of database queries and speed up your website. And if you are not using WordPress then you need to check and optimize your database then use some website cache functionality. For this, you may buy expert’s support via system@sangkrit.net on per hour per terminal basis. Continue reading What Is Increased Time To 1st Byte? How It Affects Your Website’s Speed?

How To Find Your WordPress Hostname & Server IP Address?

Not generally but many a times website owners require knowing their hostname and server IP address, it is only useful in certain situations like many security plugins and SSL certificate extensions asks you for your IP and host information to set up configuration settings and there are many more reasons.

Continue reading How To Find Your WordPress Hostname & Server IP Address?

How To Run Many WordPress Installations In One Database?

Unlike to SANGKRIT.net’s hosting accounts, there are many hosting providers who give you a limited amount of MySQL databases and resources. So in this tutorial we will be telling you how you can run multiple WordPress installations on a single MySQL database. Yes, a single database can run multiple websites including single and multisite WordPress installations or even you can also run other CMS application like Mediawiki with in that. Let us see how.

Continue reading How To Run Many WordPress Installations In One Database?

Best Plugins For Optimizing & Managing Database Tables In WordPress

Generally there are two ways webmasters use for optimization database tables, some do it via phpMyAdmin which works from your webserver or your web hosting account and the other way is using a database optimization plugin which is more easy and user friendly way. There are hundreds of database optimization plugins available in WordPress plugin repository which confuses the new WordPress users.

Continue reading Best Plugins For Optimizing & Managing Database Tables In WordPress

Check CPU Performance Of PHP & MySQL Server Right From WordPress Admin Area

With PHP/MySQL CPU performance statistics WordPress plugin you can check your CPU performance of your PHP and MySQL database time to time right from your WordPress  admin area dashboard.

Continue reading Check CPU Performance Of PHP & MySQL Server Right From WordPress Admin Area

Easiest Way To Clean Unnecessary Tables In WordPress Database

WPDBTotalCleaner is the new WordPress plugin which provides you a very easy way to clean up unnecessary Database tables from your WordPress site. The plugin is simple, lightweight and is compatible with bot single and multisite WordPress installations.

Continue reading Easiest Way To Clean Unnecessary Tables In WordPress Database

How To Change WordPress Site Domain Name By Editing Its Database ?

We have already discussed about changing your website domain name or URL by editing functions.php file and by editing wp-config.php file. Now this tutorial explains you how you can update your website web address to new one (when you are migrating your website to a new domain) directly by updating your WordPress site’s MySQL database.

Continue reading How To Change WordPress Site Domain Name By Editing Its Database ?

Top 5 Plugins For Migrating Your Blog To WordPress

Thinking of migrating your blog to WordPress, here are 5 cool plugins that can help you doing that in a better and easy way possible and ofcourse I am takling about WordPress.Org self hosted blog not WordPress.Com. If you are migrating your blog from Blogger then you must read this post.

Continue reading Top 5 Plugins For Migrating Your Blog To WordPress

Add Debug Bar Showing Query, Cache, And Other Helpful Information On Debugging In WordPress

WordPress developers launched WordPress.Com’s debug bar for Self Hosted WordPress Blogs . It adds a debug menu to WP admin bar that shows query, cache, and other helpful debugging information. Good for developers.

Continue reading Add Debug Bar Showing Query, Cache, And Other Helpful Information On Debugging In WordPress

Display Your Host’s PHP, MySQL & Memcached Information On WordPress Dashboard

Display your host’s PHP, MySQL & Memcached (if installed) information on your WordPress site dashboard.

Continue reading Display Your Host’s PHP, MySQL & Memcached Information On WordPress Dashboard

How To Grant Privilege To Any MySQL Database User ?

GRANT command is be used for giving privilege to any user for accessing database.

GRANT PRIVILEGES ON DATABASE OBJECTS TO USER@HOST IDENTIFIED BY ‘PASSWORD’;

Example:

For granting privilege to user  admin Use:

GRANT ALL PRIVILEGES ON *.* TO ‘admin@localhost’ IDENTIFIED BY ‘secret’;

For specifying the username and password which is used while staring MySQL is:

mysql –h hostname –u username –p password

When you don’t want users to access any other database tables then replace* (as shown below) with database name of that particular user whom you want to limit access to other database tables:

GRANT ALL PRIVILEGES ON ‘store’.* TO ‘admin@localhost’ IDENTIFIED BY ‘secret’;

Run given command with root permission. In the given command ‘store’ correlates to the name of database to which the privileges are assigned.

Listing MySQL Databases

For showing all database:

SHOW DATABASES;

In case you need to filter database by name:

SHOW DATABASES LIKE ‘pattern’;

For complex filtering of database use WHERE Clause:

SHOW DATABASES WHERE conditions;

With WHERE clause one can use regular expressions like ‘<‘ and ‘>’ operators, string functions etc. for filtering records returned by SHOW DATABASES.