如果是集群版的安装在你规划的需要安装mysql的虚拟机(服务器)上安装
1.安装mysql客户端
1.1 安装wget命令
yum -y install wget
1.2 下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
1.3 安装
安装1.3.mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
1.4 安装mysql客户端
yum install mysql-server
yun install mysql-devel
等待安装完毕
2.数据库字符集设置
配置mysql文件:
vim /etc/my.cnf
在最后添加配置参数
character-set-server=utf8
3.启动mysql服务
service mysqld start
或者
systemctl start mysqld
4.测试
输入mysql
命令
[root@master ~]# systemctl start mysqld
[root@master ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.42 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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.
5.设置root密码
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
设置密码
mysql> update user set authentication_string = password('root'), password_expired = 'N' where user = 'root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
6.设置mysql运行远程访问
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; #刷新权限
Query OK, 0 rows affected (0.00 sec)
7.设置开机自启
mysql> exit;
Bye
[root@master ~]# vim /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
#追加内容
service mysqld start
~
8.测试
使用SQLyog或者native工具测试连接,注意将防火墙关闭systemctl stop firewalld
测试连接成功则代表安装成功