centos7 mysql数据库安装和配置
一、系统环境
yum更新升级以后的系统版本为
(root@yl-web yl) #, cat /etc/redhat-release CentOS Linux release 7.1.1503 (核心)
二、mysql安装
一般网上给出的资料都是
# yum install mysql # yum install mysql服务器# yum install mysql-devel
安装mysql和mysql-devel都成功,但是安装mysql服务器失败,如下:
(root@yl-web yl) #, yum install mysql-serverLoaded 插件:fastestmirror Loading mirror  speeds 得到cached hostfile *,基础:,mirrors.sina.cn *,临时演员:,mirrors.sina.cn *,更新:mirrors.sina.cn No package  mysql-server 可用。 错误:,Nothing 用
查资料发现是CentOS 7版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。
有两种解决办法:
1,方法一:安装mariadb
mariadb数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。
安装mariadb,大小59 m .
(root@yl-web yl) #, yum install mariadb-server mariadb
mariadb数据库的相关命令是:
systemctl开始mariadb, #启动mariadb
systemctl停止mariadb, #停止mariadb
systemctl重启mariadb, #重启mariadb
systemctl启用mariadb, #设置开机启动
所以先启动数据库
(root@yl-web yl) #, systemctl start mariadb
然后就可以正常使用MySQL了
(root@yl-web yl) #, mysql -u root -pEnter 密码:, Welcome 用,MariaDB 监控只,Commands 最终获得with ,趁机\ g。 Your MariaDB  connection id  is 3 server 版本:5.5.41-MariaDB MariaDB 服务器 Copyright (c), 2000年,2014年,甲骨文,MariaDB Corporation Ab 以及其他信息。 Type & # 39;帮助;& # 39;,趁机& # 39;\ h # 39;, for 帮助只Type & # 39; \ c # 39;,用clear 从而current input 语句。 MariaDB [(一)]祝辞,show 数据库;+ - - - - - - - - - - - - - - - - - - - - - - + |,Database ,,,,,,,,, | +--------------------+ | |,information_schema  |,mysql ,,,,,,,,,,,, | | |,performance_schema  |,test ,,,,,,,,,,,,, | +--------------------+ 4,rows set 拷贝;(0.00,sec) MariaDB [(一)]在
安装mariadb后显示的也是,,可能看起来有点不习惯。下面是第二种方法。
2,方法二:官网下载安装mysql服务器
#, wget http://dev.mysql.com/get/mysql -社区-释放- el7 - 5. - noarch.rpm #, rpm -ivh mysql -社区-释放- el7 - 5. - noarch.rpm #, yum install mysql-community-server
安装成功后重启mysql服务。
#, service mysqld 启动
初次安装mysql,根账户没有密码。
(root@yl-web yl) #, mysql -u root Welcome 用,mysql 监控只,Commands 最终获得with ,趁机\ g。 Your MySQL  connection id  is 3 Server 版本:,5.6.26 MySQL Community Server (GPL) Copyright (c), 2000年,2015年,Oracle 和/或its 子公司只All rights 保留。 Oracle is  a registered trademark  of Oracle Corporation 和/或它的 子公司只Other names  may be trademarks of their 各自 的主人。 Type & # 39;帮助;& # 39;,趁机& # 39;\ h # 39;, for 帮助只Type & # 39; \ c # 39;,用clear 从而current input 语句。 mysql>, show 数据库;+ - - - - - - - - - - - - - - - - - - - - - - + |,Database ,,,,,,,,, | +--------------------+ | |,information_schema  |,mysql ,,,,,,,,,,,, | | |,performance_schema  |,test ,,,,,,,,,,,,, | +--------------------+ 4,rows set 拷贝;(0.01,sec) mysql>
设置密码
mysql>, set password for & # 39;根# 39;@ # 39;localhost # 39;,=密码(& # 39;密码# 39;); Query 好吧,,0,rows affected (0.00,秒) mysql>centos7系统mysql数据库如何安装及配置