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
Preface JavaScript is one of the widely used lang...
Table of contents What is VUE Core plugins in Vue...
Table of contents Nginx proxies two socket.io ser...
Rational ClearCase is a software configuration ma...
When we perform automatic discovery, there is alw...
Table of contents What is NULL Two kinds of NULL ...
How to solve the problem of 1045 when the local d...
In the previous article, I introduced the functio...
The specific code is as follows: <style> #t...
Generic load/write methods Manually specify optio...
Unique “About”-Pages A great way to distinguish yo...
Despite props and events, sometimes you still nee...
Maybe I started to think wrongly, and my descript...
Database Table A: CREATE TABLE task_desc_tab ( id...
We all know that we can use the mkdir command to ...