In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to solve the problem of modifying the datadir of MySQL under Ubuntu 10.04. the article is very detailed and has certain reference value. Interested friends must read it!
Due to the shortage of server space, you need to move the datadir of mysql under Ubuntu 10.04 from the default / var/lib/mysql to / usr/local/mysql, as follows:
1. / etc/mysql/my.cnf has been modified to: datadir = / usr/local/mysql
2.cp-a / var/lib/mysql / usr/local/
3./etc/init.d/mysql start
The problem occurred. The system reported an error and could not start mysql. The log shows: Can't find file: ". / mysql/plugin.frm' (errno:13)
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
But when mysql_upgrade is executed, the error is also reported.
After a round of online google, no solution was found.
I suddenly remembered that when I was debugging mail server, I needed to modify the chroot parameters of the system to modify the default storage directory of the system, so I decided to give it a try, which turned out to be the reason. Write down the relevant steps here so that you can share them with friends who need them.
To modify the chroot of the system, you need to modify the relevant files under / etc/apparmor.d. Here, take mysql as an example, you need to modify two files: usr.sbin.mysqld and abstractions/mysql.
1. Modify the two lines in usr.sbin.mysqld: / var/lib/mysql/ r, change it to: / usr/local/mysql/** rwk
two。 Modify the line in abstractions/mysql: / var/lib/mysql/mysql.sock rw to: / usr/local/mysql/mysql.sock rw
3. Reload the apparmor service: / etc/init.d/apparmor reload
Start mysql again at this time and it will be a success!
Revelation: not only mysql, if you need to modify the storage directory of some other system's own software, and still report an error after changing the configuration, you may need to modify the corresponding chroot! Please refer to the above method!
The key points are as follows:
1. Find the Option File that mysql loaded when it started (if there are more than one, then it must be the one that works). There is only one on my machine, which is "/ etc/mysql/my.cnf". Go in and change the value of the datadir entry to the directory you specify. It's not hard.
two。 Most importantly, transfer the contents of the original data directory (default is "/ var/lib/mysql") to the new directory, and! Definitely! Make sure that the relevant content remains the same as the original user and permission settings in the new directory. You can do it with chown and chmod. It's very simple. But if this step goes wrong, it will be troublesome to find it. When you restart mysql, you will only say that you can't connect, and it's hard to find the real reason. I installed MySQL through Package Manager under Ubuntu. After installation, the user name and group name of related files and directories are "mysql", so the new datadir should also set owner to mysql and make sure it has the appropriate permissions.
3. Not only do you need to make sure that the user / permission settings of datadir are correct, but if the datadir directory is deep, it seems to have something to do with the permissions of the directories above. In short, make sure that the user "mysql" has smooth access to the content of the new datadir, and that all necessary content has been copied to the new datadir. In MySQL, the necessary startup information such as user records is also saved in form, and these necessary database will be loaded at startup. If there is a problem with the permissions of the relevant directory, or the file does not exist at all, the startup will fail.
4. With regard to AppArmor, online sources say that you need to tell it the changes through the profile file, otherwise AppArmor will prevent mysql from accessing the new file path and mysql will not run. In my experience, I don't seem to feel the influence of AppArmor. But just to be on the safe side, according to what the Internet says, modify its profile file, on my machine is: "/ etc/apparmor.d/usr.sbin.mysqld", according to the original format of datadir content, add a few new lines:
/ my/new/datadir/ r
/ my/new/datadir/** rwk
5. Both AppArmor and mysql need to be restarted. The command to restart is:
Sudo / etc/init.d/ {apparmor | mysql} stop
Sudo / etc/init.d/ {apparmor | mysql} start
Or you can use the service command:
Sudo service {apparmor | mysql} stop
Sudo service {apparmor | mysql} start
-TroubleShooting:
The Error log file for mysql, on my machine, is "/ var/log/mysql/error.log". If something goes wrong, the real cause is recorded here. Don't worry too much about a few lines of output in the terminal. Basically, no matter what happens, you can only say that you can't connect to Server, which is useless.
These are all the contents of this article entitled "how to solve the problem of modifying the datadir of MySQL under Ubuntu 10.04". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.