mysql的安装(Linux)

如果是集群版的安装在你规划的需要安装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

在这里插入图片描述

测试连接成功则代表安装成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值