Configure Mysql virtual FTP account _ MySQL in ftp server pure-ftpd

Source: Internet
Author: User
Tags crypt
Configure Mysql virtual FTP account 1. Mysql connection in pure-ftpd on the ftp server

 [root@localhost ~]# mysql -uroot -pxxxxxx(your mysql password)

2. create a mysql authentication database

mysql>create database pureftpd;mysql>grant privileges all on pureftpd.* to pureftpuser@localhost identified by 'pureftpuser';mysql>flush privileges;mysql>use pureftpd;Mysql> create table if not exists `users`(`user` varchar(16) not null default '',`password` varchar(32) not null default '',`uid` int(11) not null,`gid` int (11) not null,`dir` varchar(128) not null default '',`quotafiles` int(10) not null default '500',`quotasize` int(10) not null default '30',`ulbandwidth` int(10) not null default '80',`dlbandwidth` int(10) not null default '80',`ipaddress` varchar(15) not null default '*',`comment` tinytext,`status` enum('0','1') not null default '1',`ulratio` smallint(5) not null default '1',`dlratio` smallint(5) not null default '1',primary key (`user`),unique key `user` (`user`))engine=innodb default charset=utf8;mysql> show tables;+--------------------+| Tables_in_pureftpd |+--------------------+| users              |+--------------------+1 row in set (0.00 sec)mysql> desc users;+-------------+---------------+------+-----+---------+-------+| Field       | Type          | Null | Key | Default | Extra |+-------------+---------------+------+-----+---------+-------+| user        | varchar(16)   | NO   | PRI |         |       || password    | varchar(32)   | NO   |     |         |       || uid         | int(11)       | NO   |     | NULL    |       || gid         | int(11)       | NO   |     | NULL    |       || dir         | varchar(128)  | NO   |     |         |       || quotafiles  | int(10)       | NO   |     | 500     |       || quotasize   | int(10)       | NO   |     | 30      |       || ulbandwidth | int(10)       | NO   |     | 80      |       || dlbandwidth | int(10)       | NO   |     | 80      |       || ipaddress   | varchar(15)   | NO   |     | *       |       || comment     | tinytext      | YES  |     | NULL    |       || status      | enum('0','1') | NO   |     | 1       |       || ulratio     | smallint(5)   | NO   |     | 1       |       || dlratio     | smallint(5)   | NO   |     | 1       |       |+-------------+---------------+------+-----+---------+-------+14 rows in set (0.15 sec)



3. create a pureftp Virtual User

mysql> insert into users values ('bev','pureftpuser','2000','2000','/var/pureftp/bev','500','30','30','50','*','','1','1','1');mysql> select * from users/G;*************************** 1. row ***************************       user: bev   password: 5bc915d575ad9c57aa0fc6e1fd719615        uid: 2000        gid: 2000        dir: /var/pureftp/bev quotafiles: 500  quotasize: 30ulbandwidth: 30dlbandwidth: 50  ipaddress: *    comment:      status: 1    ulratio: 1    dlratio: 11 row in set (0.11 sec)ERROR: No query specified

4. Note that the mysql account and password encryption method must be consistent with the confidential method supported by pureftp. Otherwise, the 530 error may occur.

mysql> update users set password=md5('pureftpuser') where user='bev';

I chose the MD5 encryption method here, so we must select MD5 when configuring the pureftp encryption method below.

5. modify the configuration document of the pureftp mysql module.

[Root @ localhost ~] # Vi/usr/local/pure-ftpd/etc/pure-ftpd.conf # MySQL configuration file (see README. mySQL) MySQLConfigFile/usr/local/pure-ftpd/etc/pureftpd-mysql.conf save exit [root @ localhost ~] # Vi/usr/local/pure-ftpd/etc/pureftpd-mysql.conf # Optional: define the location of mysql. sock if the server runs on this host. MYSQLSocket/var/lib/mysql. sock (set to your mysql. sock path) # Mandatory: user to bind the server. MYSQLUser pureftpuser # Mandatory: user password. you must have a password. MYSQLPassword pureftpuser # Mandatory: database to open. MYSQLDatabase pureftpd # Mandatory: how passwords are stored # Valid values are: "cleartext", "crypt", "sha1 ", "md5" and "password" # ("password" = MySQL password () function) # You can also use "any" to try "crypt", "sha1 ", "md5" * and * "password" MYSQLCrypt md5MYSQLGetPW SELECT Password FROM users WHERE User = '/l' MYSQLGetUID SELECT Uid FROM users WHERE User ='/l' MYSQLGetGID SELECT Gid FROM users WHERE user = '/l' MYSQLGetDir SELECT Dir FROM users WHERE User ='/l' MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User = '/l' MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User = '/ L 'explain SELECT ULRatio FROM users WHERE User = '/l' MySQLGetRatioDL SELECT DLRatio FROM users WHERE User ='/l' MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User = '/l' MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User = '/l'

6. restart pureftp to test whether the created bev has taken effect.

Okay. in the next blog, I will briefly summarize the problems encountered during the setup of pureftp and their solutions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.