mysql数据库安装和布署

 联系我们     |      2020-04-15 22:50

一、系统碰到

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-serverLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.sina.cn * extras: mirrors.sina.cn * updates: mirrors.sina.cnNo 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 -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or g.Your MariaDB connection id is 3Server 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 3Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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.

图片 1

2、远程连接装置

把在颇负数据库的全部表的富有权限赋值给位于全体IP地址的root客户。

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

如果是新客户并非root,则要先新建客商

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

当时就能够开展长途连接了。

 

本文作者starof,因知识自己在变幻莫测,小编也在不断学习成长,小说内容也波动时更新,为防止错误的指导读者,方便追根求源,请各位转发注明出处: