Here are two ways to install MySQL under Linux: Yum installation and source code compilation installation.
1. Yum Installation
(1) First check if the CentOS comes with MySQL is installed:
yum List installed | grep MySQL // If you have your own MySQL installed, uninstall it Yum -y remove mysql-libs.x86_64
(2) Download the Yum repository on the MySQL website: https://dev.mysql.com/downloads/repo/yum/,
Yum localinstall mysql57-community-release-el6--noarch.rpm// To see if the Yum Repository is successfully added yum repolist enabled | grep " mysql.*-community.* "
(3) When using the MySQL Yum Repository, the latest version selected by default is installed, or you can manually edit the file to select a version to install. For example, to install the mysql5.6 version, then mysql56-community set the enabled=1,mysql57-community settings enabled=0.
# vim/etc/Yum. repos.d/mysql-community.repo[mysql57-Community]name=mysql5.7Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/Enabled=0Gpgcheck=1Gpgkey=file:///Etc/pki/rpm-gpg/rpm-gpg-key-mysql# Enable to use MySQL5.6[Mysql56-Community]name=mysql5.6Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/Enabled=1Gpgcheck=1Gpgkey=file:///Etc/pki/rpm-gpg/rpm-gpg-key-mysql
(4) Installing MySQL
Yum Install Mysql-community-server
(5) Start MySQL service
# service Mysqld Start
The following output indicates that the MySQL installation was successful:
Starting mysqld:[OK]
2. Source code Compilation install MySQL
(1) First install the source code required to compile the package
Yum Install Make gcc-c++ cmake bison-devel ncurses-devel
(2) Download and unzip the installation package
wget http://cdn.mysql.com/downloads/mysql-5.6/mysql-5.6.14.tar.gztar xvf mysql-5.6. . tar. gz
(3) Compile and install (compile parameters according to the actual situation)
# CD mysql-5.6. -# CMake.-dcmake_install_prefix=/usr/local/MySQL-dmysql_datadir=/usr/local/mysql/Data-dsysconfdir=/etc-dwith_myisam_storage_engine=1 -dwith_innobase_storage_engine=1 -dwith_memory_storage_engine=1 -dwith_readline=1 -dmysql_unix_addr=/var/lib/mysql/Mysql.sock-dmysql_tcp_port=3306 -denabled_local_infile=1 -dwith_partition_storage_engine=1 -dextra_charsets= All-ddefault_charset=UTF8-ddefault_collation=utf8_general_ci# Make&& Make Install
(4) Configuring MySQL
Set permissions:
passwdchown -R mysql:mysql/usr/local/mysql
Initialize MySQL:
# cd/usr/local/mysql# scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data --user=mysql
Note: in the/ etc directory there will be a my.cnf, you need to rename this file to another name, such as:/etc/my.cnf.bak, otherwise, the file will interfere with the correct configuration of the source installed MySQL, resulting in the failure to start.
(5) Registration as a service
# cd/usr/local/mysql/support-Files
// Registration Services CP mysql.server/etc/rc.d/init.d/MySQL
// using the default configuration file CP my-default.cnf/etc/my.cnf
Set boot up # chkconfig MySQL on
(6) Start-up service
3. mysql Client
This error usually occurs when you first enter the MySQL client:
The solution is as follows:
(1) Add the following command to the/etc/my.cnf file:
(2) After restarting the MySQL service, go to the MySQL client to modify the root user's password:
update MySQL. User set authentication_string=password ("passwordwhereuser= "root"; Privileges;
(3) Comment out the command you just added and reset the password on the MySQL client:
//Set Password strength and length> SetGlobal Validate_password_policy=0;> SetGlobal Validate_password_length=1;
Change Password> Alter User 'Root'@'localhost'Identified by ' PASSWORD';
(4) If the set root user can access the remote, also need to perform:
> GRANT All Privileges on *. * to ' Root '@'%'PASSWORD' with GRANT OPTION;
> Flush Privileges;
You can then create the database, the tables, through the MySQL client.
Reference documents:
[1] https://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html
[2] Http://www.cnblogs.com/xiongpq/p/3384681.html
Install MySQL under Linux (two ways of Yum and source compilation)