MYSQL/MARIADB Database Configuration

Source: Internet
Author: User
Tags pkill

1. Start mariadb

Systemctl Start mariadb

2. Set Boot mariadb

Systemctl Enable MARIADB

First, change the user password, take root as an example

1. Know the root password, need to modify

Method A. Log into the database to modify

    1. # mysql-uroot-p/* Enter password to enter */
    2. /* First way: Edit database Fields directly */
    3. MariaDB [(none)]> use MySQL;
    4. MariaDB [mysql]> UPDATE user SET Password=password (' newpassword ') WHERE user= ' root ';
    5. MariaDB [mysql]> flush Privileges;
    6. MariaDB [mysql]> exit
    7. /* Second way: Change the password without entering mysql*/
    8. MariaDB [(none)]> SET password for ' root ' @ ' localhost ' =password (' newpassword ');
    9. MariaDB [(none)]> exit;

Method B. Using Mysqladmin

    1. /* This is not a good thing to do is that the password is displayed in the command line to clear text */
    2. # mysqladmin-uroot-poldpassword Password newpassword/* or */
    3. # mysqladmin-uroot-p Password NewPassword

2. Forgot root password, need to reset

  1. # Systemctl Stop MARIADB/* First stop the current MySQL process, or do the next step that the process already exists */
  2. # mysqld_safe--skip-grant-tables & * * Background directly this MySQL, the interface will also appear in the log, direct CTRL + C into the command line input */
  3. # Ps-ef | grep mariadb/* See the process, highlighting--skip-grant-tables*/
  4. MySQL 3607 3368 0 18:05 pts/0 00:00:00/usr/libexec/mysqld--basedir=/usr--datadir=/var/lib/mysql
  5. --plugin-dir=/usr/lib64/mysql/plugin--user=mysql--skip-grant-tables--log-error=/var/log/mariadb/mariadb.log
  6. --pid-file=/var/run/mariadb/mariadb.pid--socket=/var/lib/mysql/mysql.sock
  7. # mysql/* directly into MySQL, do not need a password, etc., do the first step in method A in either of the two ways can */
  8. MariaDB [(none)]> use MySQL;
  9. MariaDB [mysql]> UPDATE user SET Password=password (' newpassword ') WHERE user= ' root ';
  10. MariaDB [mysql]> flush Privileges;
  11. MariaDB [mysql]> exit; /* This time with the parameter--skip-grant-tables started MySQL will be required to enter the password to enter the * *
  12. # pkill MySQL/* Use Pkill to kill, kill, kill automatically after killing a */
  13. # Systemctl Start mariadb/* Starts the normal mysql*/

Second, change the MySQL parameters, take max_allowed_packet as an example

Method 1. Editing a configuration file

# VIM/ETC/MY.CNF

    1. max_allowed_packet=20m/* Maximum number of connections */
    2. Max_connections = 500
# systemctl Restart MARIADB/* Restart effective */

Method 2. Log in to the database to set, but the restart will be restored, it is recommended to directly use the above method of changing the configuration file

MariaDB [(None)]> show variables like ' Max_allowed_packet ';

    1. +--------------------+---------+
    2. | variable_name | Value |
    3. +--------------------+---------+
    4. | Max_allowed_packet | 1048576 |
    5. +--------------------+---------+
    6. 1 row in Set (0.00 sec)

MariaDB [(None)]> set global max_allowed_packet = 2*1024*1024*10; /* Adjust the query maximum run package size from the default 1M to 20m*/

MYSQL/MARIADB Database Configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.