您的位置:首页 > 运维架构 > Linux

mini CentOS7 安装 mysql

2016-03-28 17:34 441 查看
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。
linux环境:

[root@localhost ~]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

配置yum源,创建下面的文件 :

/etc/yum.repos.d/MariaDB.repo

内容如下:

[riadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.0/centos6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

#删除系统自带的包

yum remove mysql-libs

#安装mysql数据库(注意 MariaDB 区分大小写如果是小写的 mariadb就装成另外一个源的了,这个版本的有问题,折腾死我了)

yum -y install MariaDB-server MariaDB-client

#启动mysql

service mysql start

#修改mysql root密码

mysqladmin -u root password 12345

#登录mysql

mysql -h localhost -u root -p

#授权任意ip能登录数据库

Grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

#刷新权限立即生效

flush
privileges ;

到这里数据库就装好了 ,测试下

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.00 sec)

MariaDB [(none)]> use test

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

create table t_test (id int(11),userId char(36),lastLoginTime timestamp) engine=innerDB charset=utf8

insert into t_test(1,'abc',now());

select * from t_test;

MariaDB [test]> select * from t_test;

+------+--------+---------------------+

| id | userId | lastLoginTime |

+------+--------+---------------------+

| 1 | 2 | 2016-03-17 22:21:32 |

+------+--------+---------------------+

1 row in set (0.00 sec)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: