美文网首页
centos 7 安装MySQL

centos 7 安装MySQL

作者: shadow雨轩 | 来源:发表于2018-07-12 13:42 被阅读0次

一:centos7安装npm和nodejs

$ sudo curl -sL -o /etc/yum.repos.d/khara-nodejs.repo https://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repo

$ sudo yum install -y nodejs nodejs-npm

二:切换npm 国内镜像与国外镜像

1, 修改 下载仓库为淘宝镜像

npm config set registry https://registry.npm.taobao.org --global

npm config set disturl https://npm.taobao.org/dist --global

2, 如果要发布自己的镜像需要修改回来

  npm config set registry https://registry.npmjs.org/

3,安装cnpm

npm install-g cnpm--registry=https://registry.npm.taobao.org

4,修改后可以通过这个进行测试

npm config get registry

三:在CentOS7上使用yum安装MySQL 5.7

环境

CentOS 7.3 192.168.61.100

disable selinux

setenforce 0

vi /etc/selinux/config

SELINUX=disabled

yum安装MySQL

安装mysql yum repository

wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

yum localinstall mysql57-community-release-el7-11.noarch.rpm

确认yum repository已经安装

yum repolist enabled | grep "mysql.*-community.*"

mysql-connectors-community/x86_64      MySQL Connectors Community          36

mysql-tools-community/x86_64            MySQL Tools Community                47

mysql57-community/x86_64                MySQL 5.7 Community Server          187

查看MySQL版本:

yum repolist all | grep mysql

mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community    disabled

mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community -  disabled

mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community    disabled

mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community -  disabled

mysql-connectors-community/x86_64  MySQL Connectors Community    enabled:    36

mysql-connectors-community-source  MySQL Connectors Community - S disabled

mysql-tools-community/x86_64      MySQL Tools Community          enabled:    47

mysql-tools-community-source      MySQL Tools Community - Source disabled

mysql-tools-preview/x86_64        MySQL Tools Preview            disabled

mysql-tools-preview-source        MySQL Tools Preview - Source  disabled

mysql55-community/x86_64          MySQL 5.5 Community Server    disabled

mysql55-community-source          MySQL 5.5 Community Server - S disabled

mysql56-community/x86_64          MySQL 5.6 Community Server    disabled

mysql56-community-source          MySQL 5.6 Community Server - S disabled

mysql57-community/x86_64          MySQL 5.7 Community Server    enabled:  187

mysql57-community-source          MySQL 5.7 Community Server - S disabled

mysql80-community/x86_64          MySQL 8.0 Community Server    disabled

mysql80-community-source          MySQL 8.0 Community Server - S disabled

安装:

yum install mysql-community-server

启动和配置MySQL服务

修改MySQL配置文件/etc/my.cnf

datadir=/home/mysql(这块可以先cat查一下啊,有这个地址就不用配了,自己就又设置了导致报了地址找不到的错误,后来删了这行代码就解决了)

server_id = 1

character-set-server=utf8mb4

collation-server=utf8mb4_unicode_ci

default-storage-engine=INNODB

#Optimize omit

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

log-bin    = binlog

log_bin_trust_function_creators=1

binlog_format = ROW

expire_logs_days = 99

sync_binlog = 0

slow-query-log=1

slow-query-log-file=/var/log/mysql/slow-queries.log

long_query_time = 3

log-queries-not-using-indexes

explicit_defaults_for_timestamp = 1

启动MySQL服务:

systemctl start mysqld

systemctl status mysqld

查看生成mysql root用户临时密码:

grep 'temporary password' /var/log/mysqld.log

修改root用户的密码:

mysql -uroot -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

MySQL密码的修改有很多限制,通过下列命令可以让修改只受8位长度的限制 

,修改validate_password_policy参数的值

mysql>setglobal validate_password_policy=0;

Query OK, 0rows affected (0.00sec)

这样,判断密码的标准就基于密码的长度了。这个由validate_password_length参数来决定。

四:Navicat无法连接到MySQL,赋权限

输入 

grant all privileges on *.* to root@”xxx.xxx.xxx.xxx” identified by “密码”;

或者 ​GRANT ALL PRIVILEGES ON *.* TO ‘root’@’xxx.xxx.xxx.xxx’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;

这相当于是给IP-xxx.xxx.xxx.xxx赋予了所有的权限,包括远程访问权限。

然后再输入 

flush privileges; 

这相当于是重新加载一下mysql权限,这一步必须有。

.如果还是连接不到,那是不是 MySQL Server 绑定了本地地址,打开 /etc/mysql/my.cnf,

找到:bind-address = 127.0.0.1

去除 IP 地址绑定,把它改为:bind-address = 0.0.0.0

然后重启 MySQL Server:/etc/init.d/mysql restart

参考

Installing MySQL on Linux Using the MySQL Yum Repository

相关文章

  • 2018-04-19

    Centos 7 安装 tomcat7, jdk,mysql,zookeeper Centos 安装jdk 安装...

  • Zabbix/安装

    安装MySQL:如果没有安装MySQL,则需要先安装。Centos7之前: Centos7使用了MariaDB替代...

  • linux 安装mysql5.7新命令

    安装mysql新命令 CentOS7安装MySQL 在CentOS中默认安装有MariaDB,这个是MySQL的...

  • yum安装nginx,mysql,php

    centos7 一、安装nginx 安装mysql(centos7) 安装php centos8 安装php74 ...

  • centos7下安装mysql

    mysql安装 centos7下使用yum源安装mysql 因为centos7下默认没有mysql的yum源,所以...

  • HIVE搭建

    安装mysql centos7安装mariaDB安装mysql教程1安装mysql教程2安装教程3安装mysql教...

  • CentOS 7中安装 MySQL 出现了 No package

    CentOS 7 安装 mysql-server 爬坑 发现问题 在centos 6安装 mysql-server...

  • CentOS 7 安装MySQL

    (1)安装mysql Centos7通过yum安装最新MySQL (2)安装mysql 【1】安装mysql 步骤...

  • VirualBox + LNMP(CentOS) 环境

    安装内容 安装CentOS(LINUX) 安装PHP开发环境 安装MySQL 安装Nginx CentOS 7 V...

  • centos安装MySQL5.7

    centos安装MySQL5.7 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1、配置YU...

网友评论

      本文标题:centos 7 安装MySQL

      本文链接:https://www.haomeiwen.com/subject/mimpsftx.html