Get the App
SLTechnology News&Howtos  ›  Database  › 

Basic knowledge of database password management

Shulou Source: shulou.com Published: 2022-06-01 12:56:57 11月01日 Update

Title index

Summary of common sense

Summary of common sense

Basic knowledge after installing data

1. Change the user's password

Method 1: use the SET PASSWORD command

Mysql-u rootMariaDB [(none)] > SET PASSWORD FOR 'root'@'localhost' = PASSWORD (' newpass')

Method 2: edit the user table with update

Mysql-u rootMariaDB [(none)] > update mysql.user set password=PASSWORD ('weibodu') where user='root' and host='localhost'

Method 3: use client tools

Mysqladmin-u root password "newpass" if root has already set a password, use the following method mysqladmin-u root password oldpass "newpass"

two。 Delete anonymous useless account

MariaDB [(none)] > delete from mysql.user where host='127.0.0.1';MariaDB [(none)] > delete from mysql.user where host='localhost'

# mysql_secure_installation to replace the first two command line operations #

3. When you forget the root user password

Step 1: stop the mariadb service

Step 2: edit the service profile

# vim / etc/ my.cnf [mysqld] datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socksymbolic-links=0# add the following line skip-grant-tables

Step 3: restart the database service and log in

# mysql-uMariaDB [(none)] > update mysql.user set password=PASSWORD ('weibodu') where user='root' and host='localhost'

Tags: Methods passwords common sense services data commands users databases one line clients clients tools files service configuration title index accounts login configuration management Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei Linux Docker Shulou Information