Today, I installed MySQL on Linux, which is a centos system, and I use Yum to install it.
Yum install mysql-server mysql-devel mysql
There are some problems when modifying the storage directory of the data, recording the steps.
Default data store directory:/var/lib/mysql
My modified storage directory:/data/mysqldata/mysql
MySQL Modify Data directory:
1. Stop MySQL Service
Service Mysqld Stop
2, copy the original data to the new directory, the new directory does not exist please create
Mkdir-p/data/mysqldata/mysql
cp-fr/var/lib/mysql/*/data/mysqldata/mysql
3. Modify Directory Permissions
Chown Mysql:mysql-r/data/mysqldata/mysql
4. Modify the configuration file
Vi/etc/my.cnf
Modify:
Datadir=/data/mysqldata/mysql
Socket=/data/mysqldata/mysql/mysql.sock
Add to:
[MySQL]
Socket=/data/mysqldata/mysql/mysql.sock
Attach my.cnf file
[Mysqld] #datadir =/var/lib/mysqldatadir=/data/mysqldata/mysql#socket=/var/lib/mysql/mysql.socksocket=/data/ mysqldata/mysql/mysql.sockuser=mysql# disabling symbolic-links is recommended to prevent assorted security Riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid[mysql] Socket=/data/mysqldata/mysql/mysql.sock
Vi/etc/init.d/mysqld
DataDir "/data/mysqldata/mysql"
5. Prevent SELinux
Chcon-r-T Mysqld_db_t/data/mysqldata/mysql
(If step 6, start the following error, use the fifth step method of processing)
141209 23:52:32 [Warning] Can ' t create test file/data/mysqldata/mysql/localhost.lower-test141209 23:52:32 [Warning] Can ' t create test File/data/mysqldata/mysql/localhost.lower-test/usr/libexec/mysqld:can ' t find file: './mysql/ Plugin.frm ' (errno:13) 141209 23:52:32 [ERROR] Can ' t open the Mysql.plugin table. Please run Mysql_upgrade to create it.
6. Start the MySQL service
Service mysqld Start
MySQL modifies the default data store directory