Home  >  Article  >  Database  >  Modify the data storage location of MySQL database

Modify the data storage location of MySQL database

巴扎黑
巴扎黑Original
2016-11-07 11:44:431088browse

MySQL database data storage location modification

MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently a product of Oracle. MySQL is the most popular relational database management system. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software. MySQL is open source, so you don't need to pay extra. MySQL has good support for PHP, which is currently the most popular web development language. Most PHP developers will learn MySQL. MySQL can be customized and adopts the GPL protocol. You can modify the source code to develop your own MySQL system. For example, Alibaba Cloud's AliSQL.

In actual use, the data storage disk will be independent, and the data storage location of the default installed MySQL needs to be re-planned and modified. This is also the purpose of the editor's compilation of this article.

  1. Stop the database

    Modify the data storage location of MySQL database

2. Copy the original database directory to the new directory

cp -r ./var/ /data/mysql/

Set permissions

chown -R mysql:mysql / data/mysql/var/

3. Modify /etc/my.cnf, put

datadir = /usr/local/mysql/var

innodb_data_home_dir = /usr/local/mysql/var

innodb_log_group_home_dir = /usr/ local/mysql/var

changed to

datadir = /data/mysql/var

innodb_data_home_dir = /data/mysql/var

innodb_log_group_home_dir = /data/mysql/var

4. Start MySQL

/et c/ init.d/mysql start

5. Test whether it starts normally

Modify the data storage location of MySQL database

Simple operation steps, practice is very important.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn