Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

CentOS 7 tutorials for configuring and installing MySQL

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

This article mainly explains the "CentOS 7 configuration and installation of MySQL tutorial", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and study the "CentOS 7 configuration and installation of MySQL tutorial" bar!

CentOS 7 configuration-install MySQL1. Get MySQL source https://dev.mysql.com/downloads/repo/yum/2. Download the MySQL source wget https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm3. Install the MySQL source yum-y install mysql80-community-release-el7-3.noarch.rpm4. Install MySQLyum-y install mysql-community-server5. Set up Boot Boot # enable systemctl enable mysqld# disable systemctl disable mysqld# reload configuration systemctl daemon-reload6. Start MySQL#, start MySQLsystemctl start mysqld.service#, stop MySQLsystemctl stop mysqld.service# to view the running status of systemctl status mysqld.service7. Open firewall port # enable port 3306 firewall-cmd-- zone=public-- add-port=3306/tcp-- permanent# restart firewall firewall-cmd-- reload8. Get the initial password grep "password" / var/log/mysqld.log9. Set remote access authorization

Log in to MySQL

Mysql-u root-p

Modify configuration

ALTER user 'root'@'localhost' IDENTIFIED BY' *'; USE mysql;UPDATE user SET host='%' WHERE user='root';FLUSH PRIVILEGES;10. Set the backup script #! / bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbinexport PATH# database user name dbuser='root'# database password dbpasswd='root'# needs to back up the database Multiple databases use spaces to separate dbname='db_name'# backup time backtime= `date +% Y% m% d% H% M% S` # Log backup path logpath='/home/database_backup/db_name'# data backup path datapath='/home/database_backup/db_name'# Log recording header echo "[`date'+% Y/%m/%d% HAV% MHD% S`] start backup." > > ${ Logpath} / backup.log# official backup database for table in $dbname Dosource= `mysqldump-u ${dbuser}-p$ {dbpasswd} ${table} > ${logpath} / ${backtime} .sql`2 > > ${logpath} / backup.log;# backup successfully the following operations if ["$?" = = 0] Thencd $datapath# to save hard disk space, compress the database tar jcf ${table} _ {backtime} .tar.bz2 ${backtime} .sql > / dev/null# to delete the original file, leaving only the compressed file rm-f ${datapath} / ${backtime} .sql # deleted seven days before the backup, that is, only the backup find $datapath-name "* .tar.bz2"-type f-mtime + 7-exec rm-rf {}\ > / dev/null 2 > & 1echo "[`date'+% Y/%m/%d% HV% MV% S'`] backup succeeds." > > ${logpath} / backup.logelse# backup fails, then perform the following operation: echo "[`date'+% Y/%m/%d% HV% MVR% S'`] backup failed." > > ${logpath} / backup.logfidone11. Set scheduled task crontab# start crontabsystemctl start crond# stop crontabsystemctl stop crond# view running status systemctl status crond

Edit Task Profil

# Open the configuration file crontab-e# add tasks: execute script 3023 * sh / home/database_backup/db_name/backup.sh# at 23:30 every day to view scheduled tasks crontab-l Note:

Install WGET:

Yum install-y wget

Install bzip2:

Yum install-y bzip2 thank you for reading, the above is the "CentOS 7 configuration and installation of MySQL tutorials" content, after the study of this article, I believe you have a deeper understanding of CentOS 7 configuration and installation of MySQL tutorials, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Backup configuration data database tutorials tasks files learning success content password log status port script path firewall run fire prevention original Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MySQL MariaDB NVidia macOS