MySQL - Knowledge Base Archives - Hivelocity Hosting https://www.hivelocity.net/kb/tag/mysql/ Dedicated Servers, Private Cloud & Colocation Tue, 27 Feb 2024 14:36:45 +0000 en-US hourly 1 https://wordpress.org/?v=6.6 MySQL Overview in Linux https://www.hivelocity.net/kb/mysql-overview-in-linux/ Tue, 27 Feb 2024 14:36:45 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=31497 MySQL is a powerful and widely used SQL database server that plays a crucial role in web applications and services. MySQL is designed for mission-critical, heavy-load production systems, and mass-deployed software. As a fast, multi-threaded, and robust database server, it provides efficient data storage and retrieval capabilities. This MySQL Overview in Linux article will provide …

MySQL Overview in Linux Read More »

The post MySQL Overview in Linux appeared first on Hivelocity Hosting.

]]>
MySQL is a powerful and widely used SQL database server that plays a crucial role in web applications and services. MySQL is designed for mission-critical, heavy-load production systems, and mass-deployed software. As a fast, multi-threaded, and robust database server, it provides efficient data storage and retrieval capabilities. This MySQL Overview in Linux article will provide insight to important information and steps in general basic procedures that you could do with MySQL. A few key benefits are listed below for running MySQL on a webserver.

  1. Being free and open-source, MySQL provides this level of freedom without any cost.
  2. MySQL’s storage-engine framework supports demanding applications.
  3. Features like high-speed partial indexes, full-text indexes, and unique memory caches contribute to superior database performance.
  4. MySQL can handle more than 50 million rows, making it suitable for large-scale applications.
  5. MySQL runs on various operating systems, including Linux, Windows, and UNIX variants.

Database Engines  

MySQL supports different storage engines for data storage. Two common ones are InnoDB and MyISAM. These engines handle data differently under the surface, but you interact with the database in the same way. Each engine has its own advantages and disadvantages, so choose based on your specific requirements.

  InnoDB  MyISAM
Locking Mechanism InnoDB uses row-level locking, allowing concurrent access to different rows. Ideal for scenarios with frequent updates and inserts. MyISAM employs full table-level locking, which can hinder concurrent access during writes. Better suited for read-heavy, static tables.
Crash Recovery InnoDB has robust crash recovery mechanisms. It ensures data consistency even after unexpected shutdowns. MyISAM lacks advanced crash recovery features. Data integrity may be compromised after crashes.
Foreign Keys InnoDB supports foreign keys and relationship constraints. – Ensures referential integrity. MyISAM does not enforce foreign keys. No built-in support for maintaining relationships.
Transactions InnoDB provides transaction support (commit, rollback). – Changes are treated as a single unit of work. MyISAM lacks transactional capabilities. Each operation is independent, no atomic transactions.
Full-Text Search InnoDB introduced full-text search indexes in MySQL 5.6. MyISAM has supported full-text indexes for a long time.
Performance InnoDB is designed for high-volume data processing. – Performs well under heavy loads. MyISAM excels in read-heavy scenarios. Efficient for static data with minimal updates.

Other Database Engines

In addition to InnoDB and MyISAM, there are several other database engines used in various systems.

  • Oracle Database
  • Microsoft SQL Server
  • PostgreSQL
  • MongoDB
  • Redis
  • Elasticsearch
  • SQLite
  • Cassandra

Basic Functions of MySQL Management in a Linux Server

Logging into MySQL

There are two methods to login to a MySQL user.

The first method involves logging into MySQL as root using the mysql command that will drop you right into the MySQL command line interface.

  • If you are not aware of your MySQL root password, you could use the command my_print_defaults -s client in your server’s command line interface to print the password used by the root user.
Logging into MySQL as root
Logging into MySQL as root

The second method involves logging into a specific MySQL user, whether root or any other. This process is done using the command mysql -u root -h localhost -p, here the “root” portion is the username that would need to change depending on the account being used.

Logging into MySQL as root Using Specific user Input
Logging into MySQL as root Using Specific user Input

Viewing The Default and Available Storage Engines

To view all available storage engines and their support status, use query SHOW ENGINES;

The Support column indicates whether an engine can be used. If the Support value for InnoDB is DEFAULT, it means InnoDB is the default storage engine for your MySQL server.

Viewing the Default and Available Storage Engines in your MySQL
Viewing the Default and Available Storage Engines in your MySQL

Viewing Users List

Once you’re in the MySQL client, execute the following query to retrieve a list of usernames that have access to the server SELECT user FROM mysql.user; , for a list of distinct users use SELECT DISTINCT User FROM mysql.user;

MySQL User List
MySQL User List
MySQL Distinct User List
MySQL Distinct User List

Viewing Databases List

List all databases in MySQL, you can use the following query SHOW DATABASES;

MySQL Database List
MySQL Database List

Inspecting Database Health Status  

For MySQL, you can use the mysqlcheck utility to monitor overall database health. It performs checks and repairs if needed. To check all databases on a system you could use the following command mysqlcheck –all-databases within the command line interface of the Linux system.

MySQL Database Health Check
MySQL Database Health Check

Backing Up Databases

To dump (backup) MySQL databases, you can use the mysqldump utility. This tool creates a set of SQL statements that can be used to recreate the original database. The command to use is mysqldump -u root -p –all-databases > all_databases_backup.sql which will create a dump of the databases in a file, “all_databases_backup.sql”, within the directory that you’ve ran the command in.

MySQL Database Dump
MySQL Database Dump

Thank you for reading and I hope that you enjoyed this MySQL Overview in Linux guide. For more guides, please check out our Knowledge Base which is updated weekly!

The post MySQL Overview in Linux appeared first on Hivelocity Hosting.

]]>
Resetting MySQL User Password https://www.hivelocity.net/kb/resetting-mysql-user-password/ Fri, 23 Feb 2024 21:25:59 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=31415 MySQL is a popular open-source database management system that can store and manipulate data. To access a MySQL database, you need to create a user account and assign it a password. The process of creating a new user and database is also being done automatically upon a creation of cPanel account and when adding domains …

Resetting MySQL User Password Read More »

The post Resetting MySQL User Password appeared first on Hivelocity Hosting.

]]>
MySQL is a popular open-source database management system that can store and manipulate data. To access a MySQL database, you need to create a user account and assign it a password. The process of creating a new user and database is also being done automatically upon a creation of cPanel account and when adding domains to said account. Resetting the MySQL user password can be very simple and can be performed using two methods as listed below in this Resetting MySQL User Password guide.

Changing MySQL User Password Using WHM/cPanel

This is the recommended method when performing a MySQL user password change when your server contains a cPanel installation.

  1. Login to your WHM/cPanel and search for “Change MySQL® User Password“.

    MySQL User Password Change Form
    MySQL User Password Change Form
  2. Select the MySQL user you wish to change the password.
  3. Ensure to type a password with a strength score of at least 80%, as shown below and press the “Change Password” once completed.
MySQL User Password Change Form Completion
MySQL User Password Change Form Completion

Changing MySQL User Password Using the Command Line Interface 

The following steps will describe the process involved in changing the MySQL user password via the command line once you’ve logged into your server via SSH or by using the Console feature in the customer portal.

  1. Login to the server as the “root” user.
  2. Type the command mysql -u root -h localhost -p to login to MySQL as the “root” user.
  3. Enter the “root” user MySQL password to login.
    1. If you are unsure of what the “root” user password is, you can use the command my_print_defaults -s client to view it in the main command prompt.
  4. Now that you are logged in to MySQL as “root” user.

    MySQL Login Prompt in Command Line
    MySQL Login Prompt in Command Line
  5. Run command SELECT user FROM mysql.user; to view a full list of available users.

    Full MySQL Users List via the Command Line
    Full MySQL Users List via the Command Line
  6. Use the following command to alter the password ALTER USER ‘pascalsuissa’@’localhost’ IDENTIFIED BY ‘MyNewPasswordis1234!’;
    1. “pascalsuissa” is the username.
    2. “MyNewPasswordis1234” is the password.
  7. Once the command has completed running, the prompt will display a “Query OK” message, indicating that the password change is now complete.

    Completion Prompt Indicating a Successful MySQL User Password Change
    Completion Prompt Indicating a Successful MySQL User Password Change

The post Resetting MySQL User Password appeared first on Hivelocity Hosting.

]]>
How to Delete a Table in MySQL https://www.hivelocity.net/kb/how-to-delete-a-table-in-mysql/ Fri, 29 Oct 2021 16:44:29 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=19537 If you need to delete a MySQL table from your system, you can do so easily using the MySQL Command Shell and the DROP TABLE command. Read on to learn all about the DROP TABLE command, and the various modifiers that can be used in conjunction with it. Deleting a Table in MySQL If you …

How to Delete a Table in MySQL Read More »

The post How to Delete a Table in MySQL appeared first on Hivelocity Hosting.

]]>
If you need to delete a MySQL table from your system, you can do so easily using the MySQL Command Shell and the DROP TABLE command. Read on to learn all about the DROP TABLE command, and the various modifiers that can be used in conjunction with it.

Deleting a Table in MySQL

If you need to delete a table from MySQL, the first step is to access the MySQL Command Shell. If you’re not sure how to do that, just type MySQL into your system’s command terminal and hit Enter.

Once you’re in the MySQL shell, you can use the command DROP TABLE, followed by the name of table you are trying to delete to permanently remove the designated table from your system. *Note: even after deleting a MySQL table, its associated privileges will remain. This means if you create a new table with the same name as the deleted table, the new table will automatically inherit the old table’s privileges.

So, let’s say you have a table named table_A that you’re trying to delete. To do so, you could use the syntax:

DROP TABLE table_A;

*Note: when using commands in the MySQL shell, you must remember to end you commands with a semicolon “;” as shown above.

Now, if you’re trying to delete a table which does not exist (or if you simply enter the table’s name wrong), you’ll receive an error output from MySQL stating that the table does not exist. While this isn’t an issue on it’s own, if your DROP TABLE statement is included as part of a script, producing an error can cause your script to get stuck.

To solve this, add the modifier IF EXISTS to the command, like so:

DROP TABLE IF EXISTS table_Z;

If the table_Z referenced above does not exist, instead of printing an error, MySQL will now print a warning, allowing your script to continue running (mostly as intended).

If you need to delete multiple tables at once, you can do so by listing all the tables you’d like to delete in the same command, separated by commas:

DROP TABLE IF EXISTS table_A, table_B, table_C;

If you are trying to delete a temporary table or are worried you might accidentally delete a non-temporary table as well, you can add the TEMPORARY modifier to your command to ensure that only temporary tables are targeted. It would look something like this:

DROP TEMPORARY TABLE IF EXISTS table_temp1;

In this instance, the command would only delete the table table_temp1 if it is already designated as temporary. Otherwise, it would report a warning that the table does not exist.

And there you have it!

 

Popular Links

Looking for more information on MySQL? Search our Knowledge Base!

Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

 

The Hivelocity Difference

Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

The post How to Delete a Table in MySQL appeared first on Hivelocity Hosting.

]]>
How to Check MySQL Version https://www.hivelocity.net/kb/how-to-check-mysql-version/ Tue, 26 Oct 2021 15:11:58 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=19532 When managing databases through MySQL it’s important to know which version/distribution of MySQL you’re running. When interfacing with external tools and plugins, your MySQL version number can be essential in determining potential incompatibilities. Luckily, finding your MySQL version is a simple task on both Linux and Windows. You can even do it on both using …

How to Check MySQL Version Read More »

The post How to Check MySQL Version appeared first on Hivelocity Hosting.

]]>
When managing databases through MySQL it’s important to know which version/distribution of MySQL you’re running. When interfacing with external tools and plugins, your MySQL version number can be essential in determining potential incompatibilities. Luckily, finding your MySQL version is a simple task on both Linux and Windows. You can even do it on both using the exact same command.

How to Check MySQL Version in both Linux and Windows

The easiest method for checking your MySQL version number is to follow MySQL with the -V command, like so:

mysql -V

When entered correctly, this command will print an output to the terminal featuring the version and distribution numbers for your current version of MySQL. The best thing about this method of checking is it’s operating system agnostic, meaning it works seamlessly across all Linux distributions as well as on Windows.

You can also check the version number from within the MySQL Command Shell, by connecting to your MySQL server. To do so, enter the command mysql and hit Enter. This will open MySQL’s specific command interface, which will then print an output showing your current MySQL server version number.

And there you have it! Two easy methods for checking your MySQL version number.

 

Popular Links

Looking for more information on MySQL? Search our Knowledge Base!

Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

 

The Hivelocity Difference

Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

The post How to Check MySQL Version appeared first on Hivelocity Hosting.

]]>
How to Uninstall MySQL https://www.hivelocity.net/kb/how-to-uninstall-mysql/ Thu, 30 Sep 2021 14:58:09 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=19531 If you find yourself needing to uninstall MySQL, it can be tricky sometimes to know if you’ve uninstalled it completely. Whether your running MySQL on Linux or Windows, just follow these instructions to uninstall MySQL and its associated data completely. How to Uninstall MySQL in Linux Need to uninstall MySQL from Linux? You can uninstall …

How to Uninstall MySQL Read More »

The post How to Uninstall MySQL appeared first on Hivelocity Hosting.

]]>
If you find yourself needing to uninstall MySQL, it can be tricky sometimes to know if you’ve uninstalled it completely. Whether your running MySQL on Linux or Windows, just follow these instructions to uninstall MySQL and its associated data completely.

How to Uninstall MySQL in Linux

Need to uninstall MySQL from Linux? You can uninstall MySQL using your Linux distributions package manager and the remove command. To do so, just follow these 2 easy steps:

  1. First, depending on which distribution of Linux you’re running, you’ll need to use one of the following package manager commands:

    • For CentOS and RedHat users:

      sudo yum remove mysql mysql-server
    • For Ubuntu and Debian users:

      sudo apt remove mysql mysql-server
    • For Fedora users (as well as for many subsidiary distributions):

      sudo dnf remove mysql mysql-server
  2. Now that MySQL has been removed, the next step is to ensure that the existing data directory is deleted as well. By default, this can be found at /var/lib/mysql. You can choose to delete this directory entirely using the remove command, but it’s typically better to simply rename the old directory to something new. This way, the data remains, in case you ever need to access it in the future, but should you reinstall MySQL, it won’t check the newly renamed file and will instead create a new directory.

    To rename the old MySQL directory use the mv command:

    sudo mv /var/lib/mysql /var/lib/mysql_directory_backup

    *Note: need a refresher on renaming in Linux? Check out this post from our Knowledge Base!

At this point, you’ve successfully uninstalled MySQL from your Linux server. If you’d like to reinstall MySQL, you can do so using your distribution’s package manager, replacing the “remove” commands used above with the install command instead:

  • For CentOS and RedHat users:

    sudo yum install mysql mysql-server

  • For Ubuntu and Debian users:

    sudo apt install mysql mysql-server

  • For Fedora users (as well as for many subsidiary distributions):

    sudo dnf install mysql mysql-server

How to Uninstall MySQL in Windows

To completely remove MySQL from your Windows system, just follow these 3 steps:

  1. First, you’ll need to uninstall MySQL from your Windows’ Control Panel. Navigate to Control Panel -> Programs and Features -> MySQL. From there, click on the option to Uninstall.
  2. Once MySQL is uninstalled, to completely remove the program, you need to ensure its data directories are removed as well. *Note: you may want to create backups of these directories before deleting them.

    1. Open a terminal window (make sure you’re running it as Administrator), and stop, then delete the MySQL service using the following two commands:

      Net stop MySQL
      Sc delete MySQL
    2. Now, navigate to the Start menu, and type in Show hidden files and folders. Select the View tab and remove the following folders from your system:

      C:\Program Files\MySQL
      C:\Program Files (x86)\MySQL
      C:\ProgramData\MySQL

      Also check if a folder exists at the location: C:\Users\[YourUsername]\AppData\Roaming\MySSQL
      If so, delete this folder as well.
  3. Once everything is uninstalled and your MySQL data directories have been deleted, simply restart your computer and confirm that the changes have taken place.

And there you have it! MySQL is uninstalled and its data directories are removed.

 

Popular Links

Looking for more information on MySQL? Search our Knowledge Base!

Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

 

The Hivelocity Difference

Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

The post How to Uninstall MySQL appeared first on Hivelocity Hosting.

]]>
How to Start, Stop, and Restart MySQL Server https://www.hivelocity.net/kb/how-to-start-stop-and-restart-mysql-server/ Tue, 21 Sep 2021 15:24:58 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=19511 When using MySQL, there are times when it’s important to know how to start, stop, or restart your MySQL server. Luckily, there are multiple, easy ways to do this. Which methods are available to you however, will depend on the operating system your running. Read on to learn how to start, stop, and restart MySQL …

How to Start, Stop, and Restart MySQL Server Read More »

The post How to Start, Stop, and Restart MySQL Server appeared first on Hivelocity Hosting.

]]>
When using MySQL, there are times when it’s important to know how to start, stop, or restart your MySQL server. Luckily, there are multiple, easy ways to do this. Which methods are available to you however, will depend on the operating system your running.

Read on to learn how to start, stop, and restart MySQL server in both Linux and Windows.

How to Start, Stop, and Restart MySQL Server in Linux

If you need to stop or restart your MySQL server on a Linux system, there are three different commands that can be used:

  1. Depending on your Linux distribution, you can change the state of MySQL using the service command.

    • To start MySQL server:

      sudo service mysqld start
    • To stop MySQL server:

      sudo service mysqld stop
    • To restart MySQL server:

      sudo service mysqld restart
  2. If you don’t have the service command available or would prefer to make changes to MySQL using a different method, you can also use the init.d command to start/stop your MySQL server.

    • To start MySQL server:

      sudo /etc/init.d/mysqld start
    • To stop MySQL server:

      sudo /etc/init.d/mysqld stop
    • To restart MySQL server:

      sudo /etc/init.d/mysqld restart
  3. Lastly, you can also use the systemctl command to start, stop, and restart applications on Linux, including MySQL.

    • To start MySQL server:

      sudo systemctl start mysqld
    • To stop MySQL server:

      sudo systemctl stop mysqld
    • To restart MySQL server:

      sudo systemctl restart mysqld

How to Start, Stop, and Restart MySQL Server in Windows

If you’re trying to start, stop, or restart your MySQL server on a Windows-based system, you can do so easily from the command line. Just follow these 3 steps:

  1. To start, you’ll first need to open a terminal window. If you don’t have this somewhere easily accessible, you can find it quickly using the Windows’ Run dialog. To open the Run dialog, just press the Windows Key + R.
  2. Next, type in “cmd and press the Enter key. This will open a new terminal window.
  3. Once you’ve opened a terminal window, just type the following commands to start or stop MySQL server:

    • To start MySQL server:

      mysqld start
    • To stop MySQL server:

      mysqld stop

*Note: depending on which version of Windows you are running, you may need the specific name of the MySQL version number you are running in order to start or stop the service. To find this, go to the start menu and search for Services. Locate the version of MySQL you are using and try the following commands, replacing “##” with your version number:

net start MySQL##

net stop MySQL##

For instance, if you’re running MySQL 8.0, replace “MySQL##” with “MySQL80”.

And there you have it! You now have several different methods for starting, stopping, and restarting MySQL server as needed.

 

Popular Links

Looking for more information on MySQL? Search our Knowledge Base!

Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

 

The Hivelocity Difference

Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

The post How to Start, Stop, and Restart MySQL Server appeared first on Hivelocity Hosting.

]]>
How to import/export mysql databases using phpmyadmin https://www.hivelocity.net/kb/how-to-import-export-mysql-databases-using-phpmyadmin/ Wed, 06 May 2015 20:03:43 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=11903 Login to the cPanel of you website account Under database options open the phpMyAdmin application.   Select your new database from the list on the left hands sidebar. Once it opens select the Import tab from the navigation menu. In the File to Import section click the Choose File button and select the SQL file …

How to import/export mysql databases using phpmyadmin Read More »

The post How to import/export mysql databases using phpmyadmin appeared first on Hivelocity Hosting.

]]>
    1. Login to the cPanel of you website account

    1. Under database options open the phpMyAdmin application.

    Database options

     

    1. Select your new database from the list on the left hands sidebar. Once it opens select the Import tab from the navigation menu.

    2. In the File to Import section click the Choose File button and select the SQL file located on your local computer.

    phpMyAdmin import section

    1. Untick the Partial Import check box, make sure the format is set to SQL and then click the Go button. The database import will now begin.

    phpMyAdmin import options

     

    1. You should receive a message informing you of the success of the import when it has finished.

    The post How to import/export mysql databases using phpmyadmin appeared first on Hivelocity Hosting.

    ]]>
    Create a MySQL Backup from Command Line – MySQL Import SQL File https://www.hivelocity.net/kb/create-mysql-backup-from-command-line-mysql-import-sql-file/ Wed, 06 May 2015 19:51:30 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=11886 When using MySQL, it’s important to keep backups of your databases to ensure you are able to restore them in the event of data loss. Downloading copies in the form of .sql files, can save you unnecessary stress and prevent future headaches. By using MySQL to import a SQL file, you can even create new …

    Create a MySQL Backup from Command Line – MySQL Import SQL File Read More »

    The post Create a MySQL Backup from Command Line – MySQL Import SQL File appeared first on Hivelocity Hosting.

    ]]>
    When using MySQL, it’s important to keep backups of your databases to ensure you are able to restore them in the event of data loss. Downloading copies in the form of .sql files, can save you unnecessary stress and prevent future headaches. By using MySQL to import a SQL file, you can even create new databases based on your existing data.

    Let’s get started by covering how to make a copy of your MySQL database.

     

    Thanks to MySQL’s built-in command line utilities, making backups of your MySQL database is easy. By using the mysqldump command available with your MySQL installation (located in the bin directory), you can easily dump a MySQL Database to a SQL file by following these three simple steps:

    1. First, log in to your server using root user
    2. Now, use the following command to make a copy of your MySQL database using the mysqldump utility.

      mysqldump –u[username] –p[password] [database_name] > [dump_file].sql

      *Note: you will need to replace the names in the command above with those specific to you. Of course, “username” and “password” will need to be replaced with your MySQL username and password. You’ll also need to replace “database_name” with the name of the specific database you wish to copy and “dump_file” with the name you’d like to give the .sql file you are creating.

      Screenshot of the command line showing the mysqldump utility being used

    3. Lastly, to make sure the command was executed and the backup file was created, on the same path use the command:

      ls –l

      You should see the database backup file listed now.

      Screenshot of the command line highlighting the newly created MySQL database backup file

    In addition to making a backup of an entire database, mysqldump can be used to make a copy of a specific table within a database as well. To copy a specific table, use the following command:

    mysqldump –u[username] –p[password] [database] [table_name] > [dump_file].sql

    *Note: same as above, you will need to replace “table_name” with the name of the specific table you are trying to copy.

     

    Importing a MySQL Database Using a .sql File

    After creating a backup of your MySQL database, the .sql file can be used to restore that database should anything happen to it. To restore your database simply use the command:

    mysql –u[username] –p[password] [database_name] < [dump_file].sql

    Additionally, the same .sql file can be used to create a new database as well. To import your .sql file into a new database, just use the following command:

    mysql –u[username] –p[password] [new_database_name] < [dump_file].sql

    After the process is complete, you should see two databases that are similar but have different names.

     

    Popular Links

    Looking for more information on MySQL? Search our Knowledge Base!

    Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

    Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

    Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

     

    The Hivelocity Difference

    Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

    With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

    Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

    The post Create a MySQL Backup from Command Line – MySQL Import SQL File appeared first on Hivelocity Hosting.

    ]]>
    Steps to Resolve the Error “Table ‘mysql.servers’ doesn’t exist” https://www.hivelocity.net/kb/steps-to-resolve-the-error-table-mysql-servers-doesnt-exist/ https://www.hivelocity.net/kb/steps-to-resolve-the-error-table-mysql-servers-doesnt-exist/#respond Wed, 30 Jan 2013 14:29:59 +0000 https://kb.hivelocity.net/?p=11135 After upgrading or with a newly installed version of Plesk, you may find yourself unable to set passwords for new database users. If you are experiencing this or are not able to do any kind of activity with the database users, check the MySQL error log. If the log shows: [ERROR] Can’t open and lock …

    Steps to Resolve the Error “Table ‘mysql.servers’ doesn’t exist” Read More »

    The post Steps to Resolve the Error “Table ‘mysql.servers’ doesn’t exist” appeared first on Hivelocity Hosting.

    ]]>
    After upgrading or with a newly installed version of Plesk, you may find yourself unable to set passwords for new database users. If you are experiencing this or are not able to do any kind of activity with the database users, check the MySQL error log. If the log shows:

    [ERROR] Can’t open and lock privilege tables: Table ‘mysql.servers’ doesn’t exist

    then referring to these steps should resolve the issue:

    1. First, log in to MySQL with admin privileges

      #mysql -uadmin -p`cat /etc/psa/.psa.shadow` -h localhost

    2. Go into your MySQL database:

      mysql> use mysql;

    3. Next, you’ll need to create a server table:

      mysql> CREATE TABLE `servers` (
      `Server_name` char(64) NOT NULL,
      `Host` char(64) NOT NULL,
      `Db` char(64) NOT NULL,
      `Username` char(64) NOT NULL,
      `Password` char(64) NOT NULL,
      `Port` int(4) DEFAULT NULL,
      `Socket` char(64) DEFAULT NULL,
      `Wrapper` char(64) NOT NULL,
      `Owner` char(64) NOT NULL,
      PRIMARY KEY (`Server_name`)
      ) ENGINE=MyISAM DEFAULT CHARSET=utf8
      COMMENT=’MySQL Foreign Servers table’;

    4. With that, a ‘Server’ table will be created.

    You should be able to operate the required database now.

     

    Popular Links

    Looking for more information on Plesk? Search our Knowledge Base!

    Interested in more articles about Control Panels? Navigate to our Categories page using the bar on the left or check out these popular articles:

    Popular tags within this category include: cPanel, WHM, Plesk, DirectAdmin, and more.

    Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

     

    The Hivelocity Difference

    Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

    With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

    Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

    The post Steps to Resolve the Error “Table ‘mysql.servers’ doesn’t exist” appeared first on Hivelocity Hosting.

    ]]>
    https://www.hivelocity.net/kb/steps-to-resolve-the-error-table-mysql-servers-doesnt-exist/feed/ 0
    How to Reset MySQL root Password https://www.hivelocity.net/kb/how-to-reset-mysql-root-password-2/ https://www.hivelocity.net/kb/how-to-reset-mysql-root-password-2/#respond Wed, 30 Jan 2013 14:16:42 +0000 https://kb.hivelocity.net/?p=11085 If you’ve forgotten or need to change your root user password in MySQL, you might be wondering what steps are necessary to reset your MySQL root password. Luckily, there are couple of ways to do this.   Using the mysqladmin Command to Change root Password If you’ve never set a root password for MySQL, the …

    How to Reset MySQL root Password Read More »

    The post How to Reset MySQL root Password appeared first on Hivelocity Hosting.

    ]]>
    If you’ve forgotten or need to change your root user password in MySQL, you might be wondering what steps are necessary to reset your MySQL root password. Luckily, there are couple of ways to do this.

     

    Using the mysqladmin Command to Change root Password

    If you’ve never set a root password for MySQL, the server does not require a password when connecting as root. If this is your first time setting up the root password, you can do so using the mysqladmin command from within the shell prompt using:

    $ mysqladmin -u root password NEWPASSWORD

    In the above instance, you would need to change “NEWPASSWORD” to whatever you would like your new password to be.

    If, however, this is not your first time setting the password and you’d like to change or update the existing root password, then you would need to enter this command:

    $ mysqladmin -u root -p'OLDPASSWORD' password NEWPASSWORD

    For example, if your old password is “abc” and you wanted to set your new password to “123456”, you would tweak the command so that it looks like this:

    $ mysqladmin -u root -p'abc' password '123456'

     

    Changing MySQL Password (Non-Root Users)

    Beyond changing the root password, you can use the mysqladmin command to change the password for non-root users as well. By replacing the “root” in the command above with the name of the user whose password you are attempting to change, you can change the password of any specific database user.

    For example, if you wanted to change the password for a user named “vivek” you could do so by entering the follow command:

    $ mysqladmin -u vivek -p'OLDPASSWORD' password NEWPASSWORD

    Just like in the examples above, you would still need to enter the user’s old password in the space marked “OLDPASSWORD” and replace the “NEWPASSWORD” at the end of the line with whatever you desire the new password to be.

     

    Manually Changing the root Password

    As mentioned earlier, using the mysqladmin command isn’t the only way to change the root password in MySQL. For those of you who prefer a more hands on approach, you can also change the root password from within the terminal by utilizing the following series of commands.

    1. First, you’ll need to stop MySQL. As the root user enter the command:
      root@server [~] /etc/init.d/mysqld stop

    2. Next, you’ll need to start MySQL server without a password. Use this command to do so:
      root@server [~] mysqld_safe –skip-grant-tables &
      Make sure you include the “&” at the end of this, as this will allow the command to run in the background

    3. Now login to MySQL using the “mysql” command:
      root@server [~] mysql

    4. Once you have access to the mysql prompt then run the following commands:
      mysql >use mysql
      mysql >UPDATE user SET Password=PASSWORD(‘NEWPASSWORD’)
      you will need to replace “user” with “root” if you are attempting to change the root password.

    5. From there, exit out of MySQL using:
      mysql >quit

    6. To finalize your changes, you’ll need to stop MySQL Server and start it back up again using:
      root@server [~]/etc/init.d/mysqld stop
      root@server [~]/etc/init.d/mysqld start

    Now you can access your mysql service by using:

    root@server [~]#mysql -u root -p

    Like the mysqladmin method above, this method can be used to change other users’ passwords as well by replacing the “user” in the “UPDATE user SET Password=PASSWORD(‘NEWPASSWORD’)” command with the name of the user whose password you are trying to change.

    And there you have it! Now you know how to set, change, and reset the root password within MySQL.

     

    Popular Links

    Looking for more information on MySQL? Search our Knowledge Base!

    Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

    Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

    Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

     

    The Hivelocity Difference

    Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

    With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

    Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

    The post How to Reset MySQL root Password appeared first on Hivelocity Hosting.

    ]]>
    https://www.hivelocity.net/kb/how-to-reset-mysql-root-password-2/feed/ 0
    How to Check and Repair a Corrupted MySQL Database Table Using SSH https://www.hivelocity.net/kb/how-to-check-and-repair-a-corrupted-mysql-database-table-using-ssh/ https://www.hivelocity.net/kb/how-to-check-and-repair-a-corrupted-mysql-database-table-using-ssh/#respond Wed, 30 Jan 2013 14:15:07 +0000 https://kb.hivelocity.net/?p=11075 In this tutorial we’ll cover how to use MySQLcheck to repair a corrupted database table. Repairing a Corrupted MySQL Database Table Please refer to the following steps: First, log in to your MySQL server using Secure Shell (SSH). Then, enter the following command at root prompt: mysqlcheck -r [database name] Where, mysqlcheck is the command …

    How to Check and Repair a Corrupted MySQL Database Table Using SSH Read More »

    The post How to Check and Repair a Corrupted MySQL Database Table Using SSH appeared first on Hivelocity Hosting.

    ]]>
    In this tutorial we’ll cover how to use MySQLcheck to repair a corrupted database table.

    Repairing a Corrupted MySQL Database Table

    Please refer to the following steps:

    1. First, log in to your MySQL server using Secure Shell (SSH).
    2. Then, enter the following command at root prompt:

    mysqlcheck -r [database name]

    Where, mysqlcheck is the command to check the database, -r is the command to repair the corrupted tables. Replace the [database name] with your actual database name.

    Please note that MyISAM is a default storage engine of MySQL, unless you change it. Mostly MyISAM is set as default engine to check and repair all the tables in the mysql database.

    If the above doesn’t work, then you can try the following commands via the Linux shell prompt.

    myisamchk -r /var/lib/mysql/[database name]/*

    Where, myisamchk is a command to check mysql database and -r is a command to repair the corrupted tables.

     

    Popular Links

    Looking for more information on MySQL? Search our Knowledge Base!

    Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

    Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

    Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

     

    The Hivelocity Difference

    Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

    With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

    Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

    The post How to Check and Repair a Corrupted MySQL Database Table Using SSH appeared first on Hivelocity Hosting.

    ]]>
    https://www.hivelocity.net/kb/how-to-check-and-repair-a-corrupted-mysql-database-table-using-ssh/feed/ 0