mini CentOS7 安裝 mysql


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)







  1. # yum install mariadb-server -y //如果已安裝可以省略  
  2. # systemctl start mariadb.service //啓動服務  
  3. # systemctl enable mariadb.service //開機啓動服務  
  4. # mysql -u root -p //登錄mysql  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章