Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL installation and initial password modification

Shulou Source: shulou.com Published: 2022-06-01 09:00:54 10月02日 Update

MySQL installation

I. system environment

Centos7 or REHL7

Download the MySQL rpm installation package (here, take 5.7 as an example)

There is no need to say much about the specific download methods, there are many on the Internet.

Delete the MariaDB database that comes with the system.

Rpm-qa | grep-I mariadb

Rpm-e-nodeps mariadb-libs

Rm-rf / etc/my.cnf

Fourth, install related dependency packages

Yum-y install perl-Data-Dumper.x86_64 perl-JSON

Upgrade and install MySQL

Tar-xvf mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar

Rm-rf mysql-community-server-minimal-5.7.17-1.el7.x86_64.rpm # remove minimum installation

Rpm-Uvh mysql-community-*.rpm

Systemctl start mysqld

Systemctl enable mysqld

Systemctl status mysqld

All right, the installation of MySQL is complete here. Additional information such as the process port of MySQL is attached:

Service name: mysqld

Process name: mysqld

Master / group of the process: mysql/mysql

Port number: TCP/3306

Main profile location: / etc/my.cnf

Database directory location: / var/lib/mysql

Initial MySQL login password modification

First, view the log file

Grep-I "password" / var/log/mysqld.log

You can see that there is a string of characters and passwords. Copy them down.

Log in to MySQL with the password found

Mysql-hlocalhost-uroot-p "Y1jNtb50Hd+x" # Note here: use single quotation marks if there is a special symbol.

Change the temporary password

Mysql > set global validate_password_policy=0

Mysql > set global validate_password_length=6

Mysql > alter user root@ "localhost" identified by "123456"

Mysql-hlocalhost-uroot-p123456 # re-log in to the database with the changed password

Mysql > show databases; # can see the concrete library

IV. Permanent password policy: modify the configuration file

Vim / etc/my.cnf

[mysqld]

Validate_password_policy=0

Validate_password_length=6

Systemctl restart mysqld # restart the service

Tags: Password data database file process login location ownership system service configuration minimum special information slogan character quotation mark mode log environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS Redmi Microsoft NVidia