Basic knowledge of database password management
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'