MySQL installation tutorial in centos 7, centos 7 MySQL
How to install MySQL in centos 7
Install MySQL
There are two differences between mysql and windows.
1) Save my. ini to/etc/my. ini
2) User Permissions, executed by individual users
1. Check whether mysql has been installed before. Run the following command:
Rpm-qa | grep-I mysql
If the following package is displayed, mysql is installed.
Mysql-4.1.12-3.RHEL4.1
Mysqlclient10-3.23.58-4.RHEL4.1
Ii. Download the mysql decompression package
Mysql-5.7.17-linux-glibc2.5-x86_64.tar (go to http://mirrors.sohu.com website to download)
Web: http://mirrors.sohu.com/mysql/MySQL-5.7/
You can also download it under the Linux operating system and enter 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 named "software" to store the mysql package to be downloaded. Enter the command "cd/software" in the directory.
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 a mysql user and put the user in the mysql Group
3. passwd mysql # set a password for the mysql user
4. decompress the mysql installation package
1. First 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、decompress the tar.gz package
Go to the/usr/local directory and enter the command cd/usr/local.
Unzip command tarzxvfmysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
Enter the directory command ll
Will find more directory mysql-5.7.17-linux-glibc2.5-x86_64
Note: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 in linux)
Change the name of the extracted file to mysql.
Input command: mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
5. Configure the startup configuration file
First, go to the support-files/file directory.
Enter the command: cd support-files/
1. Copy my. cnf to/etc/my. cnf (read automatically when mysql is started)
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 (indicating to solve the client garbled problem)
[Mysqld]
Default-storage-engine = INNODB
Character_set_server = utf8 (indicating to solve server garbled characters)
3. Copy mysql. server to the/etc/init. d/directory. [Objective: To achieve the automatic execution of mysqld-install upon 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 services recorded in the registry HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ services.
4. Modify the/etc/init. d/mysql parameters.
Run vi/etc/init. d/mysql.
Give two directory locations
Basedir =/usr/local/mysql
Datadir =/usr/local/mysql/data
5. Change owner of directory/usr/local/mysql
Run chown-R mysql: mysql/usr/local/mysql/
6. initialize the mysql database
1. initialize mysql
Mysql_install_db (old version practices)
New Version: initialization
Enter the command./mysqld -- initialize -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data
Generate a data Directory, which indicates that the database has been initialized successfully.
And the root user of mysql generates a temporary password: (record the temporary password XXX)
2. Database Encryption
Enter the command./mysql_ssl_rsa_setup -- datadir =/usr/local/mysql/data
3. Start mysql
Enter the command./mysqld_safe -- user = mysql & (& indicates submitting to the backend to run the mysql Service)
7. Enter the client
1. log on
Enter the command./mysql-uroot-p
Then enter your temporary password.
2. Change the password
Enter the command set password = password ('xxxx ')
8. Windows Remote Access to mysql of Linux Virtual Machine
Let's take a look at the database structure.
1. Disable the firewall (or open a port to the firewall) so that the window can be connected.
Enter the command systemctl stop firewalld. service
2. Authorize Windows
Enter the command mysql> grant all privileges on *. * toroot @ '%' identified by '123 ';
mysql>use mysql;mysql>select host,user from user;
[Add a remote logon 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 be automatically started upon startup
1. Add mysql Service
Enter the command chkconfig -- add mysql [mysqld-install]
2. Set mysql service to automatic
Enter the command chkconfig mysql on
3. Restart check
init 6ps –ef | grep mysql
10. Set path
Enter command vi/etc/profile
Enter the command exportPATH = $ JAVA_HOME/bin:/usr/local/mysql/bin: $ PATH
After the mysql environment variables are configured, you do not need to log on to the/usr/local/mysql/bin directory after logging on to mysql. Now you can log on to mysql under any directory.
Here we have successfully installed MySQL in the centos 7 environment.
Thank you for your support!
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.