Detailed introduction to the steps of installing MySQL in Linux centos7 environment Install MySQL MySQL has two differences from Windows 1) Save my.ini to /etc/my.ini 2) User permissions, executed by a single user 1. Check whether MySQL has been installed before, use the following command: rpm –qa | grep -i mysql If the following packages are displayed, it means that mysql has been installed mysql-4.1.12-3.RHEL4.1 mysqlclient10-3.23.58-4.RHEL4.1 2. Download the mysql decompression package mysql-5.7.17-linux-glibc2.5-x86_64.tar (download from http://mirrors.sohu.com) Website: http://mirrors.sohu.com/mysql/MySQL-5.7/ You can also download it under the Linux operating system by entering the following command wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz Create a directory software to store the MySQL package we will download later. Go to the directory and enter the command: cd /software After the download is complete, you will see an additional MySQL installation package file in the software directory. 3. Create a user and mysql directory 1. groupadd mysql #Create a mysql group 2. useradd -r -g mysqlmysql #Create mysql user and put the user into mysql group 3. passwd mysql #Set a password for the mysql user 4. Unzip the MySQL installation package 1. Move the tar.gz package to the /usr/local directory and enter the command mv /software/MySQL/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz/usr/local 2. Unzip the tar.gz package First go to the /usr/local directory and enter the command cd /usr/local Decompression command tarzxvfmysql-5.7.17-linux-glibc2.5-x86_64.tar.gz Enter the command to view the directory: You will find an additional directory mysql-5.7.17-linux-glibc2.5-x86_64 Note: There is no data directory, the my.ini file is in the support-files directory 3. Change the directory name to /usr/local/mysql (This is the default installation directory for MySQL under Linux) Rename the unzipped file to mysql Enter the command: mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql 5. Configure related startup configuration files First, go to the support-files/file directory Enter the command: cd support-files/ 1. Copy my.cnf to /etc/my.cnf (automatically read when mysql starts) Enter the command cpmy-default.cnf /etc/my.cnf 2. Solve the garbled problem Enter the command: vi /etc/my.cnf (enter editable state) Change: [mysql] default-character-set=utf8 (to solve the problem of garbled characters on the client side) [mysqld] default-storage-engine=INNODB character_set_server=utf8 (to solve the garbled character problem on the server side) 3. Copy mysql.server to the /etc/init.d/ directory [the purpose is to achieve the automatic execution effect of mysqld -install at startup] Enter the command cp mysql.server /etc/init.d/mysql (mysql is the service name) Note: The /etc/init.d/ directory is equivalent to the registry HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services, which records those services 4. Modify /etc/init.d/mysql parameters Enter the command vi /etc/init.d/mysql Give two directory locations basedir=/usr/local/mysql datadir=/usr/local/mysql/data 5. Change the owner of the directory /usr/local/mysql Enter the command chown -R mysql:mysql /usr/local/mysql/ 6. Initialize the mysql database 1. Initialize mysql mysql_install_db (old version method) New version: Initialization Enter the command ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data A data directory is generated, indicating that the database has been initialized successfully And the root user of mysql generates a temporary password: (record the temporary password XXX) 2. Encrypt the database Enter the command ./mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data 3. Start mysql Enter the command ./mysqld_safe --user=mysql & (& means submit to the background to run the mysql service) 7. Enter the client 1. Login Enter the command ./mysql -uroot -p Then enter your temporary password 2. Change password Enter the command set password=password('xxxx') 8. Window remote access to Linux virtual machine mysql Let's take a look at the database structure first 1. Turn off the firewall (or open a port to the firewall) so that window can connect Enter the command systemctl stop firewalld.service 2. Authorize Windows Enter the command mysql>grant all privileges on *.* toroot@'%' identified by '123456'; mysql>use mysql; mysql>select host,user from user; [One more remote login user record] mysql>flush privileges; 3. Remotely connect to the database, or restart (init 6). Enter the command: mysql –hIP address-uroot -p123456 9. Set the MySQL service to start automatically at boot 1. Add mysql service Enter the command chkconfig --add mysql [mysqld -install] 2. Set the mysql service to automatic Enter the command chkconfig mysql on 3. Restart and check init 6 ps –ef | grep mysql 10. Set path Enter the command vi /etc/profile Enter the command exportPATH=$JAVA_HOME/bin:/usr/local/mysql/bin:$PATH After configuring the mysql environment variables, we no longer need to go to the /usr/local/mysql/bin directory to log in to mysql in the future. Now we can log in to mysql in any directory At this point we have successfully installed MySQL in the Linux centos7 environment. Thank you all for your support! Wonderful topic sharing: MySQL different versions installation tutorial MySQL 5.6 installation tutorials for various versions MySQL 5.7 installation tutorials for various versions mysql8.0 installation tutorials for various versions 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:
|
<<: Detailed explanation of WordPress multi-site configuration under Nginx environment
>>: Let's deeply understand the event object in js
Strictly speaking, nginx does not have a health c...
I installed IE8 today. When I went to the Microso...
Statement 1: <link rel="shortcut icon"...
Preface Today I encountered a very strange proble...
As we all know, without the cd command, we cannot...
Easy installation of opencv2: conda install --cha...
Quick Reading Why do we need to monitor SQL state...
Recently, the project switched the environment an...
This article shares the specific code for randomi...
Table of contents Structural inheritance (impleme...
First of all, let's talk about the execution ...
Table of contents Create a new html file: Create ...
Operation effect html <head> <meta chars...
systemd: The service systemctl script of CentOS 7...
filter is generally used to filter certain values...