1,创建目录
在安装mysql的目录下创建一个文件夹
mkdir mysql
cd mysql
2,下载 Mysql Yum
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
安装 Yum
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
3,安装 Mysql
yum install mysql-server
4,4, 运行 Mysql
service mysqld start
5,获取初始密码
grep "password" /var/log/mysqld.log
#### 下面是返回的内容,密码也末尾
2019-04-16T08:49:16.906290Z 1 [Note] A temporary password is generated for root@localhost: w*3tUglUo=p:
6,修改密码
### 使用临时密码登陆
mysql -u root -p
### 由于 5.7 处于安全考虑,不让设置简单密码,要先更改其密码机制
set global validate_password_policy=LOW;
### 设置密码长度
set global validate_password_length=6;
### 修改密码
SET PASSWORD = PASSWORD('111111');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;
7,远程和本地访问
use mysql;
update user set host = '%' where user = 'root';
### 使配置生效
flush privileges;
8,设置字符集
### 登陆数据库后
set character_set_database=utf8;
flush privileges;
9,一些文件的存放目录
### 配置文件
/etc/my.cnf
### 数据库文件目录
/var/lib/mysql
### 日志记录文件
/var/log/ mysqld.log
### 服务启动脚本
/usr/lib/systemd/system/mysqld.service
### socket文件
/var/run/mysqld/mysqld.pid
作者:[唯爱米]
my.cnf 配置
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
网友评论