1. Install MySQL This article is installed via APT, and the latest version installed is 5.7.21 (Note: The versions installed via APT are the latest versions. After installation in this way, the startup and environment variables on the command line are already configured, and no manual configuration is required.) sudo apt-get install mysql-server If insufficient dependencies are prompted, run the following command to resolve the dependency problem. If no dependency problem occurs, then you do not need to use this command sudo apt-get install -f During the installation process, you will be prompted to enter the root user password twice. Note: After installation in this way, the startup and automatic startup are already configured, and the environment variables on the command line do not need to be configured manually. After installation, the following directories will be created: Database directory: /var/lib/mysql/ Configuration files: /usr/share/mysql (command and configuration files), /etc/mysql (such as: my.cnf) Related commands: /usr/bin (mysqladmin mysqldump and other commands) and /usr/sbin Startup script: /etc/init.d/mysql (directory of the startup script file mysql) Service management startup sudo service mysql start 2. Configure MySQL data storage path I use Alibaba Cloud, which provides me with a 20G data disk. The path after mounting is /data. Create a folder mkdir /data/mysql Copy the default installed MySql database to /data/mysql and set permissions sudo cp -R /var/lib/mysql/* /data/mysql sudo chown -R mysql:mysql /data/mysql <==Modify the access rights of the new path sudo service mysql stop <==Stop the MySQL service If it is not a new database, delete the log file rm -rf /database/mysql/ib_logfile0 rm -rf /database/mysql/ib_logfile1 Modify the Modify the startup file sudo vim /etc/apparmor.d/usr.sbin.mysqld Will Restart MySQL sudo /etc/init.d/apparmor restart sudo /etc/init.d/mysql restart Log in to MySql and verify the data directory mysql>show variables like '%dir%'; <==When datadir is displayed as /data/mysql, the modification is successful As shown in the figure MySQL is relatively easy to install via APT The following is a detailed command flow for data file migration, for reference only. root@ww:~# mkdir /data/mysql root@ww:~# sudo cp -R /var/lib/mysql/* /data/mysql root@ww:~# sudo chown -R mysql:mysql /data/mysql root@ww:~# sudo service mysql stop root@ww:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf root@ww:~# sudo vim /etc/apparmor.d/usr.sbin.mysqld root@ww:~# sudo /etc/init.d/apparmor restart [ ok ] Restarting apparmor (via systemctl): apparmor.service. root@ww:~# sudo /etc/init.d/mysql restart [ ok ] Restarting mysql (via systemctl): mysql.service. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: MySQL database SELECT query expression analysis
>>: How to turn local variables into global variables in JavaScript
Copy code The code is as follows: <style> ....
1. Introduction to keepalived Keepalived was orig...
1. display:box; Setting this property on an eleme...
This article summarizes the common commands for L...
export default ({ url, method = 'GET', da...
In cells, light border colors can be defined indi...
What is a selector? The role of the selector is t...
Today, when I was using Nginx, a 500 error occurr...
Table of contents 1. Introduction to the basic fu...
question Insufficient memory when docker installs...
<body style="scroll:no"> <tabl...
Every website usually encounters many non-search ...
Connections can be used to query, update, and est...
This article example shares the specific code of ...
1. Introduction The topic of whether to use forei...