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.
Stop the 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
Simple operation steps, practice is very important.