MySQL installation and use of the client



Install MySQL

Download MySQLyum source

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 


Create MySQLyum source

rpm -ivh mysql-community-release-el7-5.noarch.rpm


Install MySQL server

yum -y install mysql-server


Set boot up

systemctl enable mysqld && systemctl start mysqld


Character set configuration:

vim /etc/my.cnf
 
default-character-set = utf8
[mysql.server]
default-character-set = utf8
[client]
default-character-set = utf8

[mysql.server]
default-character-set = utf8
[client]
default-character-set = utf8
[mysqld]
# 设置禁用dns解析,但是,这样不能在mysql的授权表中使用主机名了,只能使用IP
skip-name-resolve
[mysqld]
# #设置连接超时时间,默认28800
wait_timeout=900
# #设置不区分大小写,
# #1表名存储在磁盘是小写的,但是比较的时候是不区分大小写
# #0表名存储为给定的大小写,比较时区分大小写 
# #2表名存储为给定的大小写,但是比较的时候是小写的
lower_case_table_names=1
#
# #设置最大连接数
max_connections = 1024
# #设置缓冲池大小,如果是专服,一般设置成系统内存的70-80%
innodb_buffer_pool_size = 12G
# #设置缓冲池实例,范围1~64
innodb_buffer_pool_instances = 6

给root用户设置密码并授权,默认密码为空
运行命令行:mysql -u root -p
运行命令行:grant all privileges on *.* to root@'%' identified by 'root' with GRANT OPTION;


MySQL client installation

Insert picture description here

Insert picture description here

Modify user password:

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

New library

Insert picture description here

Insert picture description here

Database name: jobs
Character set: utf8-UTF-8 Unicode
collation: utf8_general_ci After
filling in, click OK, double-click jobs as shown in the figure to show that the database is created successfully.

Insert picture description here

New table

Insert picture description here

Insert picture description here

Insert picture description here


database backup

vim /root/bakmysql.sh
#!/bin/bash
# Name: bakmysql.sh
# THIS IS A ShellScript For Auto DB Backup and Delete old Backup
backupdir=/storage/mysqlbak
time=`date +%Y%m%d%H%M%S`
mysqldump -hlocalhost -uLWPQ_USR -plwpq_sjzxpwd SJZXLWPQ > $backupdir/sjzxlwpq$time.sql
find $backupdir -name "sjzxlwpq*.sql" -type f -mtime+15 -exec rm {
    
    }\; > /dev/null 2>&1

Script description: The database backup path defined by /storage/mysqlbak can be customized. The file system must contain this folder-
uLWPQ_USR is the specified database user name-
plwpq_sjzxpwd is the specified database user password
SJZXLWPQ is the specified data to be backed up
sjzxlwpq$time. sql is the name of the defined database
Create a scheduled task
Run the command line: vim /etc/crontab
30 21 * * * root sh /root/bakmysql.sh
Description: Perform a backup every day at 21:30

Guess you like

Origin blog.csdn.net/zyy130988/article/details/110114098
Recommended