MySQL is currently the latest version of 5.7.x, where the MySQL version installed is stable 5.6. Version 29, and version 5.7 of the installation process is not the same, here on the CentOS 7.2 system deployment process is as follows
First, open the download link: http://www.mysql.com/downloads/, the top of the page is the Enterprise Edition, the general personal or enterprise use of Community Edition is enough, page pull to the bottom can see the download Portal:
Click on the link to enter, then select the first entry:
Here the default is 5.7.11 version, we choose 5.6 Download link to enter:
After entering, the default version is 5.6.19, for version here Select Linux-generic, which is the generic binary version
Then the above are RPM packages, we pull to the bottom of the page based on the number of operating system bits selected. tar.gz package, here choose 64-bit mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
Click Download to download to local and upload to server ready to install
Next, perform the installation process:
Release archived files: tar -xvzf mysql-5.6. -LINUX-GLIBC2. 5-x86_64. tar. GZ
Build the MySQL directory and move to the installation directory:
mkdir /usr/local/mysqlmv mysql-5.6. -LINUX-GLIBC2. 5-x86_64/usr/local/mysql//usr/local/mysql/mysql-5.6. -LINUX-GLIBC2. 5-x86_64/
Next, create the MySQL user and user group:
-r-g mysql-s/sbin/nologin MySQL
Modify the current directory permissions for MySQL permissions:
chown -R MySQL. chgrp -R MySQL.
Perform the installation: ./scripts/mysql_install_db--user=mysql
If the previous step failed to install, prompt fatal Error:please install the following Perl modules before executing./scripts/mysql_install_db:data::D Umper, then the reason is the lack of perl-module, then execute the command: yum -y install perl-module-install.noarch Install the Perl-module module, you need to download and install 98 packages, this should be patient for a while, wait for the Perl-module installation succeeds, then proceed to the previous step installation
After the installation is successful, modify the permissions to the appropriate permissions:
chown -R root. chown -R MySQL Data
Then establish the MARIADB log directory, or the next step will be error, using the command: mkdir /var/log/mariadb
Then execute the MySQL secure boot script: bin/mysqld_safe--user=mysql & After execution, then press ENTER back to the command line, no error is started successfully
Finally add MySQL to the system service: CP Support-files/mysql.server/etc/init.d/mysql.server
At this time some of the online tutorials are generally said to be started, but the start will prompt error: starting MySQL error! Couldn ' t find MySQL Server (/usr/local/mysql/bin/mysqld_safe), indicating that Mysqld_safe could not be found because the mysqld_safe is not linked to the directory indicated above, Can modify the configuration file to specify the location, perform vim/etc/my.cnf open configuration MySQL configuration file, if accidental loss can copy the MySQL installation directory under the My.cnf file to/etc/, according to the error prompt is/mysqld_ Safe cannot be found, so you should configure the Basedir property in MY.CNF as the installation directory for MySQL, which is here:/usr/local/mysql/mysql-5.6.29-linux-glibc2.5-x86_64
After configuration, save and exit, and then execute /etc/init.d/mysql.server start to start the MySQL service normally
Then you can execute bin/mysql into the MySQL interface, if there are mysql.sock error prompts, continue to edit the/etc/my.cnf file, modify the socket in which the properties are:/tmp/ Mysql.sock can, or note default, save and exit, again into the MySQL interactive interface
Enter quit to exit the interactive interface, MySQL initial password is empty, you can use Mysqladmin to set a password for MySQL server:
' 123456 '
After the modification is completed by executing the command: bin/mysql-uroot-p Enter the password and then login to MySQL
If you need to change the password later, because the MySQL database password is stored in a MySQL database in the user table, then can be implemented through SQL statements, first log in to the MySQL database at the MySQL prompt to do the following to modify the password:
mysql> use mysql;mysql> UPDATE user SET password=password ('newpass' root'; MySQL> FLUSH privileges;
The above 3 steps can be changed to the password you want, and the next time it takes effect, now the database can be used in the local normal,
Later, MySQL can be added to the environment variable, easy to enter MySQL directly into the, without adding a path, this is optional, according to their own needs can be
Now also pay attention to a problem, although through the command line can be entered, but we have written from other host program is unable to connect to this server, in the production environment this certainly is not possible, so we have to open the authorization for all the host, so as to be able to access the normal, first we login MySQL, Then execute the following command to open the root user's authorization to all hosts:
' Root '@'%'setpassword' with GRANT option;mysql > FLUSH privileges;
The first line of the instruction of the% represents all host sources, SetPassword can be set and local MySQL different passwords, of course, in general, the same can be done, after the execution of the above instructions, MySQL can be immediately connected from the outside network, the MySQL basic installation configuration is completed
Install MySQL database under Linux