Centos7 Installing and configuring mysql5.6 Perfect Tutorial

Source: Internet
Author: User
Tags mysql client

CENTOS7 replaces the default database MySQL with MARIADB, which is not good news for developers who want to use MySQL. However, there are countless tutorials on the web about installing MySQL databases on Linux, but most tutorials are flawed. Today, to help the people you need, write down the CENTOS7 installation configuration mysql5.6 Tutorial. Well, don't talk much, on the tutorial:

First, install MySQL

1, download the installation package Mysql-5.6.34-linux-glibc2.5-x86_64.tar (can go to the official website download: http://dev.mysql.com/downloads/mysql/)

2, the unloading system comes with the MARIADB


Open the terminal terminal:

[[email protected] ~]# rpm-qa|grep mariadb//query out installed Mariadb[[email protected] ~]# rpm-e--nodeps file name//uninstall MARIADB, file A file called the above command is queried


3, delete the MY.CNF under the ETC directory

[Email protected] ~]# RM/ETC/MY.CNF

4. Execute the following command to create the MySQL user group

[[email protected] ~]# Groupadd MySQL

5. Execute the following command to create a user named MySQL and join the MySQL user group

[[email protected] ~]# useradd-g MySQL MySQL

6. Put the downloaded compressed package into the/usr/local/directory (through the MV to move the file/usr/local/)

7. Unpack the installation package

[Email protected] ~]# TAR-XVF Mysql-5.6.34-linux-glibc2.5-x86_64.tar

Note: If the compressed package is: mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz,

The decompression command is: TAR-ZXVF mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz

8. Rename the extracted folder to MySQL

[[Email protected] local]# mv extracted folder name MySQL

9. Create a new profile my.cnf under etc and add the code to the file:

Of course, there are also simple ways: Copy a copy of the my.cnf file directly to/etc, and then modify it.

e g:copy a copy of the my-default.cnf file under/usr/local/mysql/support-files/to/etc

The command is: [[email protected] support-files]# CP my-default.cnf/etc/my.cnf

Then, configure the My.cnf file in the/etc directory

[Email protected] support-files]# VIM/ETC/MY.CNF

Edit the MY.CNF code with the VIM editor as follows:

[mysql]# set MySQL client default character set Default-character-set=utf8 socket=/var/lib/mysql/mysql.sock[mysqld]skip-name-resolve# Set 3306 Ports port = 3306 socket=/var/lib/mysql/mysql.sock# Set the installation directory for MySQL basedir=/usr/local/mysql# Set the data storage directory for the MySQL database datadir=/usr/local/mysql/data# the maximum number of connections allowed max_connections=200# The character set used by the service side defaults to the 8-bit encoded latin1 character set character-set-server=utf8# the default storage engine that will be used when creating a new table Default-storage-engine=innodblower_case_ table_name=1max_allowed_packet=16m

10. Go to install MySQL software catalog

[[email protected] ~]# cd/usr/local/mysql[[email protected] mysql]# chown-r mysql:mysql./Modify the current directory to have a MySQL user [[Emai L protected] mysql]#/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/ data/Installing the Database

Note: If you perform the last command above, the following issues occur:

FATAL Error:please Install the following Perl modules before executing./scripts/mysql_install_db:data::D umper

Workaround: Install the autoconf Library

Command: Yum-y install autoconf//This package will be installed when the Data:dumper module installation is complete re-executing the last command above

Go back to the third command above to continue the operation:

[[email protected] mysql]# chown-r mysql:mysql Data modifies the owner of the current data directory as a MySQL user

The installation of this database is complete!

Second, configure MySQL

1. Grant MY.CNF Maximum Permissions

[Email protected] ~]# chown 777/etc/my.cnf

To set the start-Up service control script:

2. Copy the startup script to the resource directory

[email protected] mysql]# CP./support-files/mysql.server/etc/rc.d/init.d/mysqld

3. Increase MYSQLD Service control script execution permissions

[Email protected] mysql]# chmod +x/etc/rc.d/init.d/mysqld

4. Add mysqld service to system service

[Email protected] mysql]# chkconfig--add mysqld

5, check whether the MYSQLD service has been effective

[Email protected] mysql]# chkconfig--list mysqld

The command output resembles the following result:

Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Indicates that the MYSQLD service is in effect and starts automatically with the system boot at the 2, 3, 4, 5 runlevel, and can be used to control the start and stop of MySQL later using the service command

Command: Service mysqld start and service mysqld stop

6. Start Mysqld

[[Email protected] mysql]# service mysqld start

7. Add the MySQL bin directory to the PATH environment variable and edit the ~/.bash_profile file

[Email protected] mysql]# vim ~/.bash_profile

At the end of the file, add the following information:

Export path= $PATH:/usr/local/mysql/bin

Then press the ESC key

Continue with the SHIFT key plus the colon to play it out:

Then enter WQ carriage return

The following command is executed as soon as the modified content takes effect:

[Email protected] mysql]# source ~/.bash_profile

8, login to the root account of MySQL, the default is no password

[Email protected] mysql]# mysql-uroot-p

To enter the password, go directly to the carriage.

9. Set root account password to root (can also be changed to the password you want)

Mysql>use mysqlmysql>update User Set Password=password (' root ') where user= ' root ' and host= ' localhost ';mysql> Flush privileges;

10, set the remote host login, note the following your username and your password changed to you need to set the user and password

Mysql>grant all privileges on * * to ' your username ' @ ' percent ' identified by ' your password ' withgrant OPTION;

"Reprint, Unknown Source"

Centos7 Installing and configuring mysql5.6 Perfect Tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.