mini CentOS7 安装 mysql

来源:互联网 发布:mac dmg 沙盒 编辑:程序博客网 时间:2024/06/10 23:40


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不区分大小写:

 vi /etc/my.cnf.d/server.cnf 

在[mysqld]节下加入 :

#让MYSQL大小写敏感(1-不敏感,0-敏感)

lower_case_table_names=1


#启动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)








0 0
原创粉丝点击