mysql安装

 环境介绍:

  系统:CentOS release 6.8 (Final)

  mysql:mysql-5.7.17

mysql 部署:

1、下载mysql 包

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

2、安装依赖包

yum -y install openssl-devel libaio-devel pcre-devel

3、安装mysql并创建用户,目录

tar -xf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
useradd -M mysql -s /sbin/nologin
chown mysql.mysql mysql-5.7.17-linux-glibc2.5-x86_64
mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql-5.7.17
ln -s /usr/local/mysql-5.7.17 /usr/local/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
mkdir -p /home/mysql/data
chown mysql.mysql /home/mysql/data

4、配置mysql 配置文件

vim /etc/my.cnf
[mysqld]
user = mysql
port = 3306
server_id = 1
autocommit = 1
character_set_server = utf8mb4
max_connections = 150
max_connect_errors = 20
basedir = /usr/local/mysql
datadir = /home/mysql/data
socket = /home/mysql/data/mysql.sock
symbolic-links = 0
replicate-wild-ignore-table = information_schema.%,performance_schema.%
log-error=/home/mysql/data/error.log
pid-file=/home/mysql/data/mysql.pid
innodb_page_size = 8192
innodb_buffer_pool_size = 1G
## Bin-log
log-bin = /home/mysql/data/mysql-bin
binlog_format = row
expire_logs_days = 30
### Show log
slow_query_log
long_query_time = 0.1
slow_query_log_file = /home/mysql/data/slow_query.log
### Relay log
master_info_repository = TABLE
relay_log_info_repository = TABLE
relay_log = relay.log
relay_log_recovery = 1
slave_skip_errors = ddl_exist_errors
## GTID
gtid_mode = on
enforce-gtid-consistency = true
#
[client]
port = 3306
socket = /home/mysql/data/mysql.sock

5、mysql 初始化

/usr/local/mysql/bin/mysqld  --initialize-insecure

6、设置mysql 变量

echo 'export PATH=/usr/local/mysql/bin:${PATH}' >> /etc/profile

7、设置mysql 密码

[root@m0 local]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 238
Server version: 5.7.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> set password = password('vick_password');
mysql> flush privileges ;
mysql> quit

8、使用密码登录验证,用户名root 密码刚设置的 能登录就OK 了;

[root@m0 local]# mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 238
Server version: 5.7.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

posted @ 2017-06-19 14:03  vick.wang  阅读(157)  评论(0编辑  收藏  举报