MySQL tips in Linux

In this article, we will teach you practical training tips about Mysql. In this section, the tutorials are briefly presented and we only try to show you the instructions.

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. The MySQL source code is freely available because it was originally developed by Oracle. MySQL is written in C and C++ and is compatible with all major operating systems. MySQL can be used for a variety of applications but is most commonly found on Web servers.

The current stable release is MySQL 8.0.25 and was released on May 11, 2021. Key highlights of the latest release include:

  • InnoDB & XML enhancements.
  • Transactional data dictionary.
  • Enhanced support for Native JSON data and document store functionality.
  • Common Table Expressions.
  • Windows Functions.
  • Error log improvements such as error numbering & reduced verbosity.

And so much more. You can check out the release notes for comprehensive coverage of all the features and enhancements.

1. How to change user password on MySQL #

For mysql database server version 5.7.6 or newer #

Mysql change user password using the following method:


mysql -u root -h localhost -p
ALTER USER 'userName'@'localhost' IDENTIFIED BY 'New-Password-Here';

Read more tips about changing MySQL user passwords here.

For mysql database server version 5.7.5 or older #

$ mysql -u root -p
mysql> use mysql;

SET PASSWORD FOR 'user-name-here'@'hostname' = PASSWORD('new-password');

2. How to Change MySQL Data Folder : #

Stop Mysql service and then edit my.cnf below parameters (add if not existed)

[mysqld] datadir=/your/new/dir/  

then move data to New directory :

# cp -R -p /var/lib/mysql /new/data/dir

After Finishing migrating data to a new dir, you can start Mysql.


Powered by BetterDocs