centos7 mysql数据库安装和配置
2019独角兽企业重金招聘Python工程师标准>>>
一、系统环境
yum update升级以后的系统版本为
[root@yl-web yl]# cat /etc/redhat-release CentOS Linux release 7.1.1503 (Core)
二、mysql安装
一般网上给出的资料都是
#yum install mysql #yum install mysql-server #yum install mysql-devel
安装mysql和mysql-devel都成功,但是安装mysql-server失败,如下:
[root@yl-web yl]# yum install mysql-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile* base: mirrors.sina.cn* extras: mirrors.sina.cn* updates: mirrors.sina.cn No package mysql-server available. Error: Nothing to do
查资料发现是CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。
有两种解决办法:
1、方法一:安装mariadb
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
安装mariadb,大小59 M。
[root@yl-web yl]# yum install mariadb-server mariadb
mariadb数据库的相关命令是:
systemctl start mariadb #启动MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重启MariaDB
systemctl enable mariadb #设置开机启动
所以先启动数据库
[root@yl-web yl]# systemctl start mariadb
然后就可以正常使用mysql了
[root@yl-web yl]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.41-MariaDB MariaDB ServerCopyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec)MariaDB [(none)]>
安装mariadb后显示的也是 MariaDB [(none)]> ,可能看起来有点不习惯。下面是第二种方法。
2、方法二:官网下载安装mysql-server
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server
安装成功后重启mysql服务。
# service mysqld restart
初次安装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 | +--------------------+ 4 rows in set (0.01 sec)mysql>
设置密码
mysql> set password for 'root'@'localhost' =password('password'); 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 'password';
如果是新用户而不是root,则要先新建用户
mysql>create user 'username'@'%' identified by 'password';
此时就可以进行远程连接了。
转载于:https://my.oschina.net/u/3049482/blog/3035736
centos7 mysql数据库安装和配置相关推荐
- ubuntu删除安装的mysql数据库_Ubuntu下MySQL数据库安装与配置与卸载
安装: sudo apt-get install mysql-server mysql-client 一旦安装完成,MySQL 服务器应该自动启动.您可以在终端提示符后运行以下命令来检查 MySQL ...
- MySQL数据库安装,配置My.ini文件
最近在做项目开发时用到了MySql数据库,在看了一些有关MySql的文章后,很快就上手使用了.在使用的过程中还是出现了一些问题,因为使用的是绿色免安装版的MySql所以在配置的时候出现了一些问题,该篇 ...
- MySQL数据库安装与配置详解
目录 一.概述 二.MySQL安装 三.安装成功验证 四.NavicatforMySQL下载及使用 一.概述 MySQL版本:5.7.17 下载地址:http://rj.baidu.com/soft/ ...
- linux下centos安装mysql数据库_Linux CentOS 下的MySQL数据库安装与配置-阿里云开发者社区...
安装mysql yum -y install mysql yum -y install mysql-server yum -y install php-mysql yum -y install mys ...
- centos72安装mysql配置密码_MySQL数据库之170419、Centos7下完美安装并配置mysql5.6
本文主要向大家介绍了MySQL数据库之170419.Centos7下完美安装并配置mysql5.6 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. linxu环境: centos ...
- mysql windows 管道连接,科技常识:Windows Server 2016 MySQL数据库安装配置详细安装教程...
今天小编跟大家讲解下有关Windows Server 2016 MySQL数据库安装配置详细安装教程 ,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关Windows Server 2016 ...
- 《深入浅出MySQL:数据库开发、优化与管理维护(第2版)》一一第 1 章 MySQL的安装与配置...
第 1 章 MySQL的安装与配置 深入浅出MySQL:数据库开发.优化与管理维护(第2版) 近几年,开源数据库逐渐流行起来.由于具有免费使用.配置简单.稳定性好.性能优良等优点,开源数据库在中低端应 ...
- ubuntu14.04使用MySQL数据库安装配置Hive 1.2.1
ubuntu14.04使用MySQL数据库安装配置Hive 1.2.1 一.准备Mysql已经安装好.本人装的是navicat,图形化界面. 并在本地用root用户建立了test数据库 二 ...
- 《大型数据库技术》MySQL数据库安装配置及基础使用
文章目录 1.下载安装MySQL 1.1 搜索MySQL下载页面 1.2 查看各种MySQL版本 1.3 安装配置MySQL 2.数据库基本操作 2.1 创建数据库 2.2 创建关系表 2.3 插入数 ...
最新文章
- onInterceptTouchEvent和onTouchEvent调用时序
- html设置图片不可拖拽,js css3实现图片拖拽效果
- 北京某公司.NET面试题
- 基于深度学习的病理_组织病理学的深度学习(第二部分)
- 2021-09-26 关于打开Ubuntu的main universe restricted
- linux中的文件权限drm解释,DRM内核源码分析之三
- Matlab图像标题_title
- QQ帐户的申请与登陆 (25 分)(map映射)
- java中的控制执行流程
- 倾角传感器原理及市场现状浅析
- 10页PPT,看懂 SaaS 客户生命周期
- 本草纲目pdf彩图版下载_本草纲目pdf下载|本草纲目彩色插图版PDF完整版_ - 极光下载站...
- 快速查毒及电脑防毒的解决方案
- 《牧羊少年奇幻之旅》之水晶店老板
- 一文读懂iOS如何使用TestFlight进行测试
- stm32 hid游戏手柄程序
- java 保存gif图片_java gif图片保存处理逻辑
- C语言学习必看的N本书-续(一定要看呵)
- 喜讯 | 南京南方电讯有限公司荣膺“2021中国年度优选雇主”称号
- 聊聊云原生时代湖仓一体建设
热门文章
- django 默认查询条件_Python之Django系列-创建第一个应用-4
- mysql简单聚合函数根据条件单表查询
- Android开发(2) | 广播 Broadcast 的应用——强制下线功能
- Linux网络编程实例详解
- 使用Python作为计算器
- java i o是什么流_Java I/O流的总结
- tcp通讯一次最多能发送多少数据?_关于TCP/IP,必须知道的十个知识点
- 关于python语言的编程模式、哪个说法正确_测验1: Python基本语法元素 (第1周) 单选题+程序题...
- 【历史回顾】Linux发展一览
- 中国历史上影响最大的10首诗