In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to modify the default storage path of MySQL". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
There is no doubt that MySQL is a good choice for storing data under Linux. The default storage path for MySQL is / var/lib/mysql. In the past, the database has not been very large, with a total size of about ten gigabytes, there is no pressure to put it on the default path. But today, because a new database is imported, the import data alone is 30 gigabytes, which is a tragedy in an instant, because there is not enough hard disk partition space for the / directory. Therefore, modifying the configuration and migrating the database storage path to the appropriate place has become the most labor-saving choice.
Stop the mysql service and prepare the data
Because this is modified in the middle of the run, there is some data left over from history. The database service should be stopped first, using Fedora 19, the command can be as follows
# service mysqld stop
Then properly transfer the data from the content under the default location / var/lib/mysql to the target location. For example, / home/mysql
Modify the configuration file
My.cnf
First, you need to modify the configuration file / etc/my.cnf. There are words like datadir and socket. The meaning is self-evident, which is to modify their paths. Of course, this my.cnf may appear elsewhere, and if it is a new user, it may not even be found, but it doesn't matter.
Ls / usr/share/mysql/
You can see some mysql-XXX-cnf, you can choose some of them as templates, modify them, and drop / etc.
Get_mysql_option
In addition to cnf, you also need to modify a get_mysql_option setting, which is really unbearable.
Most of the online versions are previous versions, saying that the file "/ etc/rc.d/init.d/mysqld" should be modified-in fact, this script does not exist for fedora 19.
Looking at the error message, you can see that the error message is as follows:
[root@f-argcv etc] # systemctl status mysqld.service
Mysqld.service-MariaDB database server
Loaded: loaded (/ usr/lib/systemd/system/mysqld.service; enabled)
Active: failed (Result: exit-code) since Wed 2013-10-23 19:38:22 HKT; 8s ago
Process: 4936 ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID (code=exited, status=1/FAILURE)
Process: 4935 ExecStart=/usr/bin/mysqld_safe-basedir=/usr (code=exited, status=0/SUCCESS)
Process: 4913 ExecStartPre=/usr/libexec/mysqld-prepare-db-dir% n (code=exited, status=0/SUCCESS)
Oct 23 19:38:20 f-argcv systemd [1]: Starting MariaDB database server...
Oct 23 19:38:21 f-argcv mysqld_safe [4935]: 131023 19:38:21 mysqld_safe Logging to'/ var/log/mysqld.log'.
Oct 23 19:38:21 f-argcv mysqld_safe [4935]: 131023 19:38:21 mysqld_safe Starting mysqld daemon with databases from / home/mysql/data
Oct 23 19:38:21 f-argcv mysqld_safe [4935]: 131023 19:38:21 mysqld_safe mysqld from pid file / var/run/mysqld/mysqld.pid ended
Oct 23 19:38:22 f-argcv systemd [1]: mysqld.service: control process exited, code=exited status=1
Oct 23 19:38:22 f-argcv systemd [1]: Failed to start MariaDB database server.
Oct 23 19:38:22 f-argcv systemd [1]: Unit mysqld.service entered failed state.
The source of the problem seems to be / usr/libexec/mysqld-wait-ready. Check and modify basedir and other parameters, and then run.
Other methods
No, there's a last resort: back up your data, uninstall it, reinstall it-it's convenient to have yum here.
Then configure the file, especially modify / usr/bin/mysql_install_db, where the ldata parameter
Mysql_install_db
Can
Postscript
Later, the machine was reinstalled and var was assigned a separate expandable partition. Personally, I think this is the most comfortable setting.
This is the end of the content of "how to modify the default storage path for MySQL". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.