mysql Modify the location directory of data

Specific operations:
  1. Stop MySQL
  and start -cmd
  net stop mysql5
  2. Copy the original database directory to the new directory
  1. Copy the data directory in C:\ProgramData\MySQL\MySQL Server 5.5\ to
  D:\Program Files\MySQL\MySQL Server 5.5\ directory (self-built directory)
3. Modify MySQL configuration file
  1. Open my.ini in C:\ProgramData\MySQL\MySQL Server 5.5\data\ directory with Notepad and
  find datadir="C:\ProgramData \MySQL\MySQL Server 5.5\data"
  in front of # to comment
  out Add a line below
  datadir="D:\Program Files\MySQL\MySQL Server 5.5\data" After the
  modification is completed, save and exit.
  4. Restart MySQL
  1. Start-
  cmd net start mysql5
  2. Enter MySQL console
  Start -All Programs-MySQL-MySQL Server 5.5-MySQL 5.5 Command Line Client
  prompts to enter the password of MySQL root account, enter and press Enter to enter MySQL console
show variables like '%datadir%'; #Query the MySQL database storage directory
If the query is displayed as D:\Program Files\MySQL\MySQL Server 5.5\data\, it means the modification is successful!
  Use the data file backup under data to restore the database.


If you modify the location of innodb_data_home_dir, you need to copy the files under the file.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326425484&siteId=291194637