Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Source code installation and uninstallation of mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Unloading

First, delete the relevance of the old version of mysql

one。 Check to see if MySQL is installed on the server

Check to see if the package is installed:

Rpm-qa | grep mysql

Yum list mysql* removes previous versions of mysql-related software

Yum remove mysql mysql-server mysql-libs compat-mysql51

Rm-rf / var/lib/mysql

Rm / etc/my.cnf download mysql

# download rpm installation package #

1. Configure the YUM source

Download the YUM source rpm installation package: https://dev.mysql.com/downloads/repo/yum/ from the MySQL official website

Download the mysql source installation package

Shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

Install the mysql source

Shell > yum localinstall mysql57-community-release-el7-8.noarch.rpm

Check whether the MySQL source is installed successfully shell > yum repolist enabled | grep "mysql.-community."

[root@localhost ~] # yum repolist enabled | grep "mysql.-community."

Mysql-connectors-community/x86_64 MySQL Connectors Community 51

Mysql-tools-community/x86_64 MySQL Tools Community 63

Mysql57-community/x86_64 MySQL 5.7 Community Server 267

Seeing the figure above indicates that the installation is successful.

Installation

2. Install MySQL

Shell > yum install mysql-community-server

3. Start the MySQL service

Shell > systemctl start mysqld

Check the startup status of MySQL

Shell > systemctl status mysqld

[root@localhost ~] # systemctl status mysqld

● mysqld.service-MySQL Server

Loaded: loaded (/ usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: active (running) since Mon 2018-05-07 14:36:16 UTC; 11min ago

Docs: man:mysqld (8)

Http://dev.mysql.com/doc/refman/en/using-systemd.html

Main PID: 36800 (mysqld)

CGroup: / system.slice/mysqld.service

└─ 36800 / usr/sbin/mysqld-daemonize-pid-file=/var/run/mysqld/mysqld.pid

May 07 14:36:03 localhost systemd [1]: Starting MySQL Server...

May 07 14:36:16 localhost systemd [1]: Started MySQL Server.

4. Boot and start

Shell > systemctl enable mysqld

Shell > systemctl daemon-reload

Check whether the boot settings are successful

Chkconfig-- list | grep mysql*

Mysqld 0: off 1: close 2: enable 3: enable 4: enable 5: enable 6: close stop login mysql

Mysql-u root-p

# if you forget your password to solve, check the following problem

7. Modify the root local login password

After the mysql installation is complete, a default password is generated for root in the / var/log/mysqld.log file. Find the root default password in the following ways, and then log in to mysql to modify it:

Shell > grep 'temporary password' / var/log/mysqld.log

Shell > mysql-u root-p

Mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' MyNewPass4passport'

Or

After entering mysql, we first change the login password. "

Mysql > set password for 'root'@'localhost'=password (' 123qazure')

The new password is written in parentheses

Note: mysql5.7 installs the password Security check plug-in (validate_password) by default. The default password check policy requires that passwords must contain uppercase and lowercase letters, numbers and special symbols, and must be no less than 8 digits in length. Otherwise, ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error will be prompted, as shown in the following figure:

You can view information about password policies through the msyql environment variable:

Mysql > show variables like'% password%'

MySQL official website password policy details: http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy

Modify password policy

Add validate_password_policy configuration in / etc/my.cnf file to specify password policy

Select one of 0 (LOW), 1 (MEDIUM), 2 (STRONG), and choose 2 requires a password dictionary file.

Validate_password_policy=0

If you do not need a password policy, add the following configuration to the my.cnf file to disable it:

Validate_password = off

Restart the mysql service for the configuration to take effect:

Systemctl restart mysqld

Default profile path:

Configuration file: / etc/my.cnf

Log file: / var/log//var/log/mysqld.log

Service startup script: / usr/lib/systemd/system/mysqld.service

Socket file: / var/run/mysqld/mysqld.pid

# reset mysql password #

If you forget the root password, restore it as follows:

Systemctl stop mysql # shut down the mysql service

Find /-name my*.cnf # find my.cnf configuration file (find my.cnf file)

Add a sentence to the paragraph of [mysqld]: skip-grant-tables saves and exits vi.

Systemctl start mysql # # enable mysql service

Mysql-u root

Update mysql.user set authentication_string=password ('123qwe') where user='root' and Host =' localhost'

Or (update mysql.user set password=PASSWORD ('password') where user='root';)

Flush privileges

Exit

Systemctl restart mysql # restart the mysql service

1. View the initialization password:

[root@lone-centos67 ~] # grep 'temporary password' / var/log/mysqld.log

Modify the password

Mysql > alter user root@localhost identified by 'xxx'

The new password requires that uppercase and lowercase letters, numbers and symbols be included.

Turn off password complexity verification:

Add validate_password=off to my.cnf

Update user set host ='% 'where user =' root'

Mysql > select host, user from user; Authorization Law. For example, if you want myuser to connect to the mysql server from any host using mypassword.

GRANT ALL PRIVILEGES ON. TO 'myuser'@'%' IDENTIFIED BY' mypassword' WITH GRANT OPTION

If you want to allow the user myuser to connect to the mysql server from the host with ip 192.168.1.3, and use mypassword as the password

GRANT ALL PRIVILEGES ON. TO 'myuser'@'192.168.1.3' IDENTIFIED BY' mypassword' WITH GRANT OPTION

8. Be careful

Note:

1. [the following sentence must be executed, otherwise you will not be able to log in]

Mysql > flush privileges

two。 If the user cannot log in locally, execute the following at this time

GRANT ALL PRIVILEGES ON. TO 'root'@'localhost.localdomain' IDENTIFIED BY' 123456 'WITH GRANT OPTION

# flush privileges

Turn off the firewall

# # #

Note: the firewall must be turned off, otherwise it cannot be connected remotely.

Linux7 turn off the firewall:

1. View firewall status: systemctl status firewalld

two。 Check to see if the firewall service is started when powered on: systemctl is-enabled firewalld

3. Turn off and check the firewall: systemctl stop firewalld / systemctl status firewalld

4. Disable firewall (boot does not boot) systemctl disable firewalld / systemctl is-enabled firewalld

# initialize multi-instance database #

1) 5.1.X initialization command: (mysql.bin)

Mysql_install_db-basedir=/application/mysql-datadir=/data/3306/data-user=mysql

Mysql_install_db-basedir=/application/mysql-datadir=/data/3307/data-user=mysql

2) 5.5.32 initialization command: (cd / application/mysql/scripts)

. / mysql_install_db-- basedir=/application/mysql-- datadir=/data/3306/data-- user=mysql

. / mysql_install_db-- basedir=/application/mysql-- datadir=/data/3307/data-- user=mysql

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report