MySQL installation and database storage directory migration under CentOS

Source: Internet
Author: User

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

RPM–IVH mysql57-community-release-el7-8.noarch.rpm

Yum Install Mysql-server

Enter/etc Edit my.cnf on the last line plus skip-grant-tables skip MySQL password verification

Service mysqld Restart Restart database

Mysql-u root directly into the database without a password

Use MySQL to enter the MySQL database

Execute SQL command: Update mysql.user set Authentication_string=password (' Password ') where user= ' root ' and Host = ' localhost '; To change the root password

Flush Privileges Submit Command

Exit MySQL

/ETC/MY.CNF Edit Profile Comment last line

Service mysqld Restart Restart database

MYSQL-UROOT-P Login


Turn on remote connections
Alter user ' root ' @ ' localhost ' identified by ' Fuzapassword ' Reset password
GRANT all privileges on * * to ' root ' @ '% ' identified by ' Fuzapassword ' with GRANT OPTION

Flush privileges Submit Execution Results

MySQL Database storage Directory Migration

1. Stop the MySQL service
Service Mysqld Stop

2. Create a destination folder under the target folder you want to move
mkdir Mysqldata

3. Change user group/user to Mysql:mysql
CHOWN-VR Mysql:mysql mysqldata/

4. Change access rights to 700
CHMOD-VR mysqldata/

5. Copy the database files to the destination folder
cp-av/var/lib/mysql/*/mysqldata

6. Modify the data storage directory in the database configuration file
Vi/etc/my.conf
Datadir=/var/lib/mysql change to Datadir=/mysqldata.

7.service mysqld Start

MySQL installation and database storage directory migration under CentOS

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.