linux下安装mysql(mariadb)

yum安装软件(官网很慢)

yum install  mariadb  发现版本如下,版本特别低,且安装包特别小,
    
    mariadb                        x86_64                   1:5.5.60-1.el7_5                   base                   8.9 M
    
    2.我们可以配置mariadb官方的yum源(官方的mariadb包一定是最新的,最好的,功能最全的,但是下载速度可能很慢)
    配置官方mariadb的yum源步骤
    1.新建一个yum源仓库
        touch /etc/yum.repos.d/Mariadb.repo 
    2.在这个yum源仓库文件中,添加仓库url地址
        [mariadb]
        name = MariaDB
        baseurl = http://yum.mariadb.org/10.1/centos7-amd64
        gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
        gpgcheck=1
        
    3.一条命令安装mariadb
    yum install MariaDB-server MariaDB-client -y

由于官方的下载网速忒慢了,我们学习使用阿里云的mariadb数据库!!

重命名这个Mariadb.repo文件

mv /etc/yum.repos.d/Mariadb.repo  /etc/yum.repos.d/Mariadb.repo.bak 

使用阿里云的mariadb

yum install mariadb-server mariadb -y  

启动mariadb数据库

systemctl   start/stop/status/restart    mariadb 

初始化数据库

mysql_secure_installation

登录数据库

mysql -uroot -p 

设置mariadb数据库支持中文

vim /etc/my.cnf
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
log-error=/var/log/mysqld.log
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

重启数据库服务

systemctl restart mariadb 

登录新的数据库,查看中文编码设置

MariaDB [(none)]> \s
10.查看数据库的编码设置,以及表的设置
    show create database qishi1;
    show create  table   shenqu;

 

posted @ 2019-01-10 19:52  从入门到出师  阅读(756)  评论(0编辑  收藏  举报