centos7 mysql数据库安装和配置(转, 未验证)
一、系统环境
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 Server Copyright (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';
此时就可以进行远程连接了。
本文作者starof,因知识本身在变化,作者也在不断学习成长,文章内容也不定时更新,为避免误导读者,方便追根溯源,请诸位转载注明出处:http://www.cnblogs.com/starof/p/4680083.html有问题欢迎与我讨论,共同进步。
centos7 mysql数据库安装和配置(转, 未验证)的更多相关文章
- centos7 mysql数据库安装和配置
一.系统环境 yum update升级以后的系统版本为 [root@yl-web yl]# cat /etc/redhat-release CentOS Linux release 7.1.1503 ...
- Mysql数据库安装和配置
http://blog.csdn.net/pipisorry/article/details/46773507 Mysql数据库安装和配置.mysql语法.特殊符号及正则表达式的使用.MySQL备份与 ...
- 菜鸟的《Linux程序设计》学习——MySQL数据库安装、配置及基本操作
1. MySQL数据库: 在涉及到一些大型的Web系统或者嵌入式软件的开发时,都少不了用数据库来管理数据.在Windows操作系统下,使用过各种各样的数据库,如:sqlServer.Oracle.My ...
- 阿里云 centos7.X mysql数据库安装、配置
前言 1024阿里云搞活动,ecs云服务新用户促销活动,活动连接就不贴了,买了之后暂时不知道要做啥,想着先安装mysql数据库. 步骤 root用户登录进来 1.配置mysql的yum源,yum lo ...
- MySQL数据库安装,配置My.ini文件
最近在做项目开发时用到了MySql数据库,在看了一些有关MySql的文章后,很快就上手使用了.在使用的过程中还是出现了一些问题,因为使用的是绿色免安装版的MySql所以在配置的时候出现了一些问题,该篇 ...
- MySQL数据库安装与配置详解(图文)
接下来看一下如何安装mysql数据库. 由于有更详细的教程资源,因此参考别人的文章以整理.安装教程参考自博客园文章http://www.cnblogs.com/sshoub/p/4321640.htm ...
- centos7 mysql的安装与配置
用yum直接安装,不用更改配置 1. #yum install mysql #yum install mysql-server #yum install mysql-devel yum运行报错的化有可 ...
- CentOS7 MySql数据库安装配置(单实例)
一. 安装mysql-server 官网下载安装 # wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # ...
- MySQL数据库安装与配置详解
转载提示:在原文http://www.cnblogs.com/sshoub/p/4321640.html基础上修改. 目录 一.概述 二.MySQL安装 三.安装成功验证 四.NavicatforMy ...
随机推荐
- 【C++ Primer 第15章】定义派生类拷贝构造函数、赋值运算符
学习资料 • 派生类的赋值运算符/赋值构造函数也必须处理它的基类成员的赋值 • C++ 基类构造函数带参数的继承方式及派生类的初始化 定义拷贝构造函数 [注意]对派生类进行拷贝构造时,如果想让基类的成 ...
- 微信支付支付宝支付生成二维码的方法(php生成二维码的三种方法)
如果图简单,可以用在线生成 http://pan.baidu.com/share/qrcode?w=150&h=150&url=http://www.xinzhenkj.com 最简单 ...
- Oracle回收站的清理方法
http://blog.itpub.net/18841027/viewspace-1057765/
- #7 //[CQOI2014]和谐矩阵
题解: bitset优化高斯消元 无关变量为1 #include <bits/stdc++.h> using namespace std; #define eps 1e-9 #define ...
- Mysql 账号过期问题
1.ALTER USER 'root'@'localhost' PASSWORD EXPIRE; 一旦某个用户的这个选项设置为”Y”,那么这个用户还是可以登陆到MySQL服务器,但是在用户未设置新密码 ...
- BZOJ1079 [SCOI2008]着色方案 动态规划
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1079 题目概括 有n个木块排成一行,从左到右依次编号为1~n.你有k种颜色的油漆,其中第i种颜色的 ...
- unity pattern not found
在之前破解成功再次破解或者电脑上多个版本Unity往往会导致破解失败. 破解失败解决方法如下: 先用破解软件破解,虽然是破解失败但是还是可以在破解的目录下找到那个ulf文件. 这时候直接打开unity ...
- 分布式系统理论--CAP理论、BASE理论
问题的提出 在计算机科学领域,分布式一致性是一个相当重要且被广泛探索与论证问题,首先来看三种业务场景. 1.火车站售票 假如说我们的终端用户是一位经常坐火车的旅行家,通常他是去车站的售票处购买车票,然 ...
- html5 选择多张图片在页面内预览并上传到后台
版权声明:本文为博主原创文章,未经博主允许不得转载. http://blog.csdn.net/huangxin112/article/details/74956462 需求:点击选择图片(可选多张) ...
- ARIMA模型---时间序列分析---温度预测
(图片来自百度) 数据 分析数据第一步还是套路------画图 数据看上去比较平整,但是由于数据太对看不出具体情况,于是将只取前300个数据再此画图 这数据看上去很不错,感觉有隐藏周期的意思 代码 # ...