Mysql 5.7, mysql5.7

Source: Internet
Author: User

Mysql 5.7, mysql5.7

As the data stored in the MySQL database grows, the original storage space has been fully occupied, resulting in the connection failure of mysql. Therefore, you must place the stored data in another place. The following are some steps in the operation process. Write it down and check it later.

1. Modify the directory where mysql data is stored

You need to modify the datadir in the/etc/my. cnf file. By default:

datadir=/var/lib/mysql

Because my/data/directory is large, change it:

datadir=/data/mysql/

Also modify/etc/init.d/mysqldFiledatadir=”$result”Changed:

datadir=”/data/mysql”

2. Stop the mysql Service

service mysql stop

3. Create a new data storage directory

mkdir /data/mysql

4. Move the data to the new database storage directory.

mv /usr/local/mysql/data/* /data/mysql

Here is a little bit of knowledge. The innoDB engine and MyISAM engine have different data files.

For the MyISAM engine, the data file is named "*. frm ","*. MYD ","*. MYI files are stored in the corresponding database folder under the "/var/lib/mysql" directory. You can directly move these files to the new data storage directory.

For the innoDB engine, the data is stored in"$ Innodb_data_home_dir "ibdata1The structure file is stored in table_name.frm.

5. Modify mysql database directory permissions and configuration files

chown mysql:mysql -R /data/mysql/

6. Modify the socket

Modify socket,/etc/my. cnf in two places

socket=/data/mysql/mysql.sock

Create a connection file to/var/lib/mysql. sock

ln -s /data/mysql/mysql.sock /var/lib/mysql/mysql.sock

7. Restart the mysql Service

Run

service mysql restart 

When I started reading and writing the database, I found this problem:

Read/write:

ERROR 1146 (42S02): Table ** doesn't exist

Create a table:

ERROR 1005 (HY000): Can't create table ‘runoob_tbl' (errno: 13) 

Solution:

Delete the ib_logfile * file in the/data/mysql directory, so that the innoDB Engine table is normal.

Run again

mysql> REPAIR TABLE ***; 

This process may be slow for tables with large data volumes. After the execution is complete, the MyISAM engine table is also normal.

For more information about mysql, see

Database Operation Knowledge in MySQL

Mysql getting started

Mysql errors and Solutions

Mysql root Password Operation Method

The above section describes how to change the data storage location of a database in mysql 5.7. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in a timely manner, and I would like to thank you for your support for the help House website!

Related Article

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.