Considerations for MySQL database migration

Source: Internet
Author: User
Tags localhost mysql
I used MySQL on CentOS in the past. Later, because of the test requirements, I needed to migrate the website and data stored in the database to the new system for testing, the target system is RedHatEnterpriseLinuxServer (RHEL ). Since the database has never been migrated before, it immediately encountered a problem. Other issues are not listed. The permissions are only displayed in the following commands and execution results. Note: Some displays are blocked. Sun25Mar

I used MySQL on CentOS in the past. Later, because of the test requirements, I needed to migrate the website and data stored in the database to the new system for testing, the target system is RedHat Enterprise Linux Server (RHEL ).

Since the database has never been migrated before, it immediately encountered a problem.

Other issues are not listed. The permissions are only displayed in the following commands and execution results.

Note: Some displays are blocked.

 
 
  1. Sun 25 Mar 2012 05:07:30 CST
  2. Error/usr/bin/mysqlshow: Cannot list tables in ********: Can't read dir '. /********/'(errno: 13)
  3. Google keywords: mysql errno: 13
  4. Solution: the sub-database of the MySQL database must be owned by the mysql user and the mysql group. Otherwise, mysql cannot read the migrated database.
  5. [Root @ localhost mysql] # ls-al
  6. Total
  7. Drwxr-xr-x. 7 root 4096 Mar 24.
  8. Drwxr-xr-x. 48 root 4096 Mar 24 ..
  9. -Rw-r -----. 1 root 27262976 Mar 24 ibdata1
  10. -Rw-r -----. 1 root 5242880 Mar 24 ib_logfile0
  11. -Rw-r -----. 1 root 5242880 Mar 24 ib_logfile1
  12. Drwx ------. 2 root 4096 Mar 24 ********
  13. Drwx ------. 2 root 4096 Mar 24 mysql
  14. Drwx ------. 2 root 4096 Mar 24 performance_schema
  15. Drwx ------. 2 root 4096 Mar 24 ********
  16. Drwx ------. 2 root 4096 Mar 24 ********
  17. [Root @ localhost mysql] # ls/var/lib/mysql/-al
  18. Total
  19. Drwxr-xr-x. 5 mysql 4096 Mar 25.
  20. Drwxr-xr-x. 54 root 4096 Mar 24 ..
  21. -Rw ----. 1 mysql 10485760 Mar 25 ibdata1
  22. -Rw ----. 1 mysql 5242880 Mar 25 ib_logfile0
  23. -Rw ----. 1 mysql 5242880 Mar 25 ib_logfile1
  24. Drwx ------. 2 root 4096 Mar 25 ********
  25. Drwx ------. 2 mysql 4096 Mar 25 mysql
  26. Srwxrwxrwx. 1 mysql 0 Mar 25 16:23 mysql. sock
  27. Drwx ------. 2 root 4096 Mar 25 ********
  28. [Root @ localhost mysql] # chown-R mysql: mysql ./********/
  29. [Root @ localhost mysql] # chown-R mysql: mysql ./********/
  30. [Root @ localhost mysql] # service mysqld restart
  31. Stopping mysqld: [OK]
  32. Starting mysqld: [OK]
  33. [Root @ localhost mysql] # ls-al
  34. Total
  35. Drwxr-xr-x. 7 root 4096 Mar 24.
  36. Drwxr-xr-x. 48 root 4096 Mar 24 ..
  37. -Rw-r -----. 1 root 27262976 Mar 24 ibdata1
  38. -Rw-r -----. 1 root 5242880 Mar 24 ib_logfile0
  39. -Rw-r -----. 1 root 5242880 Mar 24 ib_logfile1
  40. Drwx ------. 2 mysql 4096 Mar 24 ********
  41. Drwx ------. 2 root 4096 Mar 24 mysql
  42. Drwx ------. 2 root 4096 Mar 24 performance_schema
  43. Drwx ------. 2 root 4096 Mar 24 ********
  44. Drwx ------. 2 mysql 4096 Mar 24 ********
  45. [Root @ localhost mysql] # cd/var/lib/mysql/
  46. [Root @ localhost mysql] # ls-al
  47. Total
  48. Drwxr-xr-x. 5 mysql 4096 Mar 25.
  49. Drwxr-xr-x. 54 root 4096 Mar 24 ..
  50. -Rw ----. 1 mysql 10485760 Mar 25 ibdata1
  51. -Rw ----. 1 mysql 5242880 Mar 25 ib_logfile0
  52. -Rw ----. 1 mysql 5242880 Mar 25 ib_logfile1
  53. Drwx ------. 2 root 4096 Mar 25 ********
  54. Drwx ------. 2 mysql 4096 Mar 25 mysql
  55. Srwxrwxrwx. 1 mysql 0 Mar 25 17:12 mysql. sock
  56. Drwx ------. 2 root 4096 Mar 25 ********
  57. [Root @ localhost mysql] # chown-R mysql: mysql ./********/
  58. [Root @ localhost mysql] # chown-R mysql: mysql ./********/
  59. [Root @ localhost mysql] # ls-al
  60. Total
  61. Drwxr-xr-x. 5 mysql 4096 Mar 25.
  62. Drwxr-xr-x. 54 root 4096 Mar 24 ..
  63. -Rw ----. 1 mysql 10485760 Mar 25 ibdata1
  64. -Rw ----. 1 mysql 5242880 Mar 25 ib_logfile0
  65. -Rw ----. 1 mysql 5242880 Mar 25 ib_logfile1
  66. Drwx ------. 2 mysql 4096 Mar 25 ********
  67. Drwx ------. 2 mysql 4096 Mar 25 mysql
  68. Srwxrwxrwx. 1 mysql 0 Mar 25 17:12 mysql. sock
  69. Drwx ------. 2 mysql 4096 Mar 25 ********
  70. [Root @ localhost mysql] # service mysqld restart
  71. Stopping mysqld: [OK]
  72. Starting mysqld: [OK]
  73. [Root @ localhost mysql] #

To put it bluntly, you need to pay attention to permission assignment. Because MySQL databases must be created and owned by mysql. Because in general, only the root permission is obtained after migration-664. Therefore, only the chown command is used.

Appendix:

Chown usage:

Chown-R user name: target file or directory of the user group

R indicates Recursive Execution.

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.