实验环境:CentOS7

主机(mini2) :172.16.250.247  主机名:;localhost

客户端(mini3):172.16.253.99  主机名:pxe99

#主机:配置文件的备份,修改配置文件
[root@~ localhost]#mkdir /datasmb
[root@~ localhost]#cd /etc/samba/
[root@samba localhost]#cp -av smb.conf{,.bak}
[root@samba localhost]#cp -av smb.conf.example{,.bak}
[root@samba localhost]#mv smb.conf.example smb.conf
[root@samba localhost]#vim smb.conf
[files]                  #共享系统名
    comment = mysql test
    path = /datasmb           #路径
    public = no                    #不公开,仅部分用户可见
    write list = sqltest                #可写
    browseable = no              #不可浏览,不可看
[root@samba localhost]#testparm
[root@samba localhost]#systemctl start nmb.service smb.service
[root@samba localhost]#ss -ntlu |egrep "137|138|139|445" 
udp    UNCONN     0      0      172.16.255.255:137                   *:*                  
udp    UNCONN     0      0      172.16.250.247:137                   *:*                  
udp    UNCONN     0      0         *:137                   *:*                  
udp    UNCONN     0      0      172.16.255.255:138                   *:*                  
udp    UNCONN     0      0      172.16.250.247:138                   *:*                  
udp    UNCONN     0      0         *:138                   *:*                  
tcp    LISTEN     0      50        *:139                   *:*                  
tcp    LISTEN     0      50        *:445                   *:*                  
tcp    LISTEN     0      50       :::139                  :::*                  
tcp    LISTEN     0      50       :::445                  :::*     
#添加samba用户
[root@samba localhost]#useradd sqltest
[root@samba localhost]#pdbedit -a -u sqltest
new password:
retype new password:
Unix username:        sqltest

 

[root@~ pxe99]#yum -y install samba samba-client
[root@~ pxe99]#yum -y install mariadb-server
[root@~ pxe99]#systemctl start mariadb.service
[root@~ pxe99]#ss -ntl |grep "3306"
[root@~ pxe99]#mysql_secure_installation 
[root@~ pxe99]#systemcel stop mariadb.service
[root@etc pxe99]#cd /etc/my.cnf.d/
[root@etc pxe99]#vim server.cnf
[mysqld]
skip_name_resolve=ON
innodb_file_per_table=ON
log_bin=mysql-bin
[root@etc pxe99]#vim /etc/my.cnf
[mysqld]
datadir=/mydata
#新建数据目录
[root@etc pxe99]#mkdir /mydata
[root@etc pxe99]#chown mysql:mysql /mydata
[root@etc pxe99]#ll -d  /mydata  /var/lib/mysql/
drwxr-xr-x 2 mysql mysql 4096 Jun 10 20:37 /mydata
drwxr-xr-x 5 mysql mysql 4096 Jun 10 20:26 /var/lib/mysql/

[root@etc pxe99]#systemctl start mariadb.service
[root@etc pxe99]#ss -ntl |grep "3306"
LISTEN     0      50           *:3306                     *:*   
#挂载
[root@etc pxe99]#mount -t cifs -o username=sqltest,password=123456 //172.16.250.247/sqltest /mydata
#数据库操作:
[root@mysql pxe99]#mysql
MariaDB [(none)]> CREATE DATABASE smb;

MariaDB [smb]> GRANT ALL ON smb.* TO smb@'172.16.253.99' IDENTIFIED BY "123456";
MariaDB [smb]> GRANT ALL ON smb.* TO smb@'127.0.0.1' IDENTIFIED BY "123456"
MariaDB [smb]> GRANT ALL ON smb.* TO smb@'172.16.250.247' IDENTIFIED BY "123456"
MariaDB [smb]> FLUSH PRIVILEGES;

 

#修改权限
#主机
[root@datasmb localhost]#setfacl -m u:sqltest:rwx /datasmb/

#客户端
[root@mysql pxe99]#setfacl -m u:mysql:rwx /mydata/