美文网首页
mysql安装(centos7) 2019-03-09

mysql安装(centos7) 2019-03-09

作者: _好孩子 | 来源:发表于2019-03-22 14:01 被阅读0次

1.卸载Mariadb

查询所安装的MariaDB组件:

[root@localhost logs]# rpm -qa | grep Maria*

    MariaDB-server-5.5.49-1.el7.centos.x86_64

    MariaDB-common-5.5.49-1.el7.centos.x86_64

    MariaDB-client-5.5.49-1.el7.centos.x86_64

卸载数据库:

[root@localhost logs]# yum -y remove maria*

删除数据库文件:(如果存在则删除,不存在就算了)

[root@localhost logs]# rm -rf /var/lib/mysql/*

[root@localhost logs]# rm -f /etc/my.cnf

[root@localhost logs]# rm -rf /var/lib/mysql/

2.安装mysql

mysql-devel可以用yum源安装:

[root@localhost logs]#yum install mysql-devel

mysql-server和mysql-client不能用yum源,yum源只有MariaDB:

[root@localhost logs]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

[root@localhost logs]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

[root@localhost logs]# yum install mysql-community-server

安装成功后重启mysql服务。

[root@localhost logs]# service mysqld restart

或者:

[root@localhost logs]# systemctl restart mysqld.service

初次安装mysql,root账户没有密码。

[root@yl-web yl]# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> show databases;

+--------------------+

| Database          |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test              |

+--------------------+

rows in set (0.01 sec)

mysql>

设置密码

mysql> set password for 'root'@'localhost' = password('root');

Query OK, 0 rows affected (0.00 sec)

mysql>

不需要重启数据库即可生效。

在mysql安装过程中如下内容:

Installed:

mysql-community-client.x86_64 0:5.6.26-2.el7                mysql-community-devel.x86_64 0:5.6.26-2.el7

mysql-community-libs.x86_64 0:5.6.26-2.el7                  mysql-community-server.x86_64 0:5.6.26-2.el7

Dependency Installed:

mysql-community-common.x86_64 0:5.6.26-2.el7

Replaced:

mariadb.x86_64 1:5.5.41-2.el7_0          mariadb-devel.x86_64 1:5.5.41-2.el7_0   mariadb-libs.x86_64 1:5.5.41-2.el7_0

mariadb-server.x86_64 1:5.5.41-2.el7_0

所以安装完以后mariadb自动就被替换了,将不再生效。

[root@yl-web yl]# rpm -qa |grep mariadb

[root@yl-web yl]#

三、配置mysql

1、编码

mysql配置文件为/etc/my.cnf

最后加上编码配置

[mysql]

default-character-set =utf8

这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。

2、远程连接设置

把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

mysql> grant all privileges on *.* to root@'%' identified by 'root';

如果是新用户而不是root,则要先新建用户

mysql>create user 'username'@'%' identified by 'password';

3.如果是阿里云,需要开启安全组开放3306端口的外网访问权限;并关闭防火墙,命令见《centos7 防火墙》

此时就可以进行远程连接了。

4.如果运行爬虫,会报too many connection错误,作以下设置:(详情见《解决Mysql错误Too many connections的方法》)

vim /etc/my.conf

在[mysqld]下添加:

max_connections=1000

wait_timeout=100

interactive_timeout=100

max_allowed_packet=15M 

show processlist;

show variables like "max_connections"; 

show global variables like 'wait_timeout';

---------------------------

相关文章

  • Zabbix/安装

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

  • HIVE搭建

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

  • centos7下安装mysql

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

  • CentOS 7 安装MySQL

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

  • linux 安装mysql

    Centos7 安装mysql mysql 依赖libaio 所以需要首先安装libaio 检查mysql 是否...

  • 新的故事-安装MySQL

    一、安装MySQL 小目录 在windows 8.1安装mysql在centos7安装mysql通过docker安...

  • yum安装nginx,mysql,php

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

  • linux 安装mysql5.7新命令

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

  • CentOs7 安装 Mysql5.7

    CentOs7 安装 Mysql5.7 1、下载mysql源安装包 2、安装mysql源 3、检查mysql源是否...

  • aliyun.CentOS7.安装MySQL & node.20

    CentOS7 64位下MySQL5.7安装与配置(YUM) CentOS7安装MySQL5.7 1. 配置yum...

网友评论

      本文标题:mysql安装(centos7) 2019-03-09

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