登录  | 加入社区

黑狼游客您好!登录后享受更多精彩

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

查看: 410|回复: 0

常用:CentOS7MySQL数据库安装和设置

[复制链接]

195

主题

195

帖子

0

现金

黑狼菜鸟

Rank: 1

积分
0
发表于 2019-2-3 19:12:55 | 显示全部楼层 |阅读模式 来自 法国
一、体系情况
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';
此时就可以举行长途毗连了。
相干阅读:
高端私有云项目交换群,接待参加!
Docker Swarm与ceph集成测试
软互换之争:OVS VS LINUX BRIDGE
通过iptables分析OpenStack 安全组规则
NFV场景下优化KVM--低时延
一文读懂OpenStack Glance是什么
Prometheus(普罗米修斯)用户档案:动态化特性加快weaveworks云原生步伐的发展
参加运维技能讨论QQ群,群共享有N多资料,502207183,并注明都会、行业、技能方向。




上一篇:千锋成都Python培训——设置CentOS7体系假造机
下一篇:云盘算Linux技能学习视频15.4Centos7修改网卡为eth0
您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

 

QQ|申请友链|小黑屋|手机版|Hlshell Inc. ( 豫ICP备16002110号-5 )

GMT+8, 2024-5-4 16:28 , Processed in 0.135093 second(s), 44 queries .

HLShell有权修改版权声明内容,如有任何爭議,HLShell將保留最終決定權!

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表