更改默认的mysql和mongodb数据dbpath

原创文章,转载请注明来源并保留原文链接

修改mysql

sudo /etc/init.d/mysql stop
sudo cp -R -p /var/lib/mysql /newpath
sudo chown mysql:mysql /newpath
vi /etc/mysql/my.cnf
#####Look for lines beginning with /var/lib/mysql. Change /var/lib/mysql in the lines with the new path.
sudo /etc/init.d/mysql restart

修改mongodb

sudo service mongod stop
vi /etc/mongodb.conf

####
Change this:
dbpath=/var/lib/mongo

With:
dbpath=/home/myuser/data/mongo
###

cp -ra /var/lib/mongo  /home/myuser/data/mongo

chown mongodb:mongodb /home/myuser/data/mongo

sudo service mongod start

Leave a Reply

Your email address will not be published. Required fields are marked *