这个是我在网上查到的方法
Configure Samba to use a MySQL database for the password backend.
cd /tmp
wget http://us3.samba.org/samba/ftp/samba-latest.tar.gz
cd /usr/local/src
tar zxvf /tmp/samba-latest.tar.gz
cd samba-X.YZ
./configure --with-expsam=mysql
make
sudo make install
Create a database for Samba, and assign permissions for it.
mysql -uroot -p
> create database samba;
> grant all privileges on samba.* to samba@localhost identified by 'samba';
> quit;
Load the SQL schema.
mysql -uroot -p samba < /usr/local/src/samba-X.YZ/examples/pdb/mysql/mysql.dump
Edit /usr/local/samba/lib/smb.conf to taste.
NOTE: the full SQL schema must be loaded or Samba will throw an error. Even if you declare a column NULL in smb.conf, the column must actually exist in the database.