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
This article aims to clarify the relationship bet...
The role of the a tag pseudo-class: ":link&qu...
When the same function and HTML code are used mul...
The project interacts with the server, accesses t...
1. getBoundingClientRect() Analysis The getBoundi...
This article example shares with you the specific...
Translated from Docker official documentation, or...
Official documentation: So mysql should be starte...
Server matching logic When Nginx decides which se...
What is a carousel? Carousel: In a module or wind...
union execution For ease of analysis, use the fol...
Docker version 1.13.1 Problem Process A MySQL con...
First of all, this post is dedicated to Docker no...
1. Installation version details Server: MariaDB S...
<!DOCTYPE html> <html lang="en"...