Hello everyone, I am warm-hearted big belly

Mysql 5.6.26 mysql 5.6.26

Dev.mysql.com/get/Downloa…

2. Upload the downloaded package to the CentOS VM and decompress the package

[root @ locahost] # tar XVF MySQL - 5.6.26-1. Linux_glibc2. 5. X86_64. RPM - bundle. The tar MySQL server - 5.6.26-1. Linux_glibc2. 5. X86_64. RPM MySQL - Shared - 5.6.26-1. Linux_glibc2. 5. X86_64. RPM MySQL - devel - 5.6.26-1. Linux_glibc2. 5. X86_64. RPM MySQL - the client - 5.6.26-1. Linux_glibc2. 5. X86_64. RPM MySQL - Shared - compat - 5.6.26-1. Linux_glibc2. 5. X86_64. RPM MySQL - embedded - 5.6.26-1. Linux_glibc2. 5. X86_64. RPM MySQL - test - 5.6.26-1. Linux_glibc2. 5. X86_64. RPMCopy the code

Cenos7 seems to come with mariadb by default. Uninstall mariadb before installing it. If grep does not exist, skip it.

[root @ localhost] # RPM - qa | grep mariadb mariadb - libs - 5.5.41-2. El7_0. X86_64 [root @ localhost] # RPM -e -- nodeps Mariadb - libs - 5.5.41-2. El7_0. X86_64Copy the code

4. Start the installation (there are many RPM packages decompressed. You can install them all at once or only install the server and client)

[root@localhost~]# RPM -ivh MySQL-*. RPM Warning: mysql-client-5.6.26-1. Linux_glibc2.5.x86_64. Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1: MySQL - devel - 5.6.26-1. Linux_glibc2 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [14%] 2: MySQL - the client - 5.6.26-1. Linux_glibc # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [29%] 3: MySQL - test - 5.6.26-1. Linux_glibc2. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [43%] 4: MySQL - embedded - 5.6.26-1. Linux_gli # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [57%] 5: MySQL -shared - compat - 5.6.26-1. Linu# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [71%] 6: MySQL - Shared - 5.6.26-1. Linux_glibc # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [86%] 7: MySQL server - 5.6.26-1. Linux_glibc # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] warning: user mysql does not exist - using root warning: group mysql does not exist - using root FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db: Data::DumperCopy the code

Here called the two warnings and an error, the warning is to prompt the machine does not exist a mysql account and mysql user group is prompt to initialize the data errors Here we set up mysql user, tips are already exists, it seems in the above warning was installed for us, can also be installed in advance before start the installation, So there’s no warning

[root@localhost ~]# groupadd mysql
groupadd: group 'mysql' already exists
[root@localhost ~]# useradd -r -g mysql mysql
useradd: user 'mysql' already exists
Copy the code

FATAL ERROR: Please install the following Perl modules before executing /usr/bin/mysql_install_db:

Data::Dumper

I don’t know what this error is, but since it prompts you to install Perl modules, install it and initialize it

[root@localhost ~]# yum install -y perl-Module-Install.noarch
Loaded plugins: fastestmirror, langpacks
base
Copy the code

5. Modify the configuration file

Example Modify the configuration file path

[root@localhost~]# cp /usr/share/mysql.my-default. CNF /etc/my.cnf [root@localhost~]# vim /etc/my.cnf [mysqld] default-storage-engine = innodb innodb_file_per_table collation-server = utf8_general_ci init-connect = 'SET NAMES utf8' character-set-server = utf8Copy the code

Mysql > initialize database. FATAL ERROR is FATAL

[root@localhost~]# /usr/bin/mysql_install_db Installing MySQL system tables... 2016-09-24 16:28:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-09-24 16:28:49 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26) 2016-09-24 16:28:49 7938 [Note] InnoDB: Using atomics to ref count buffer pool pages ... The latest information about MySQL is available on The web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as /usr/my.cnf and will be used by default  by the server when you start it. You may edit this file to change server settings WARNING: Default config file /etc/my.cnf exists on the system This file will be read by default by the MySQL server If you do not  want to use this, either remove it, or use the --defaults-file argument to mysqld_safe when starting the serverCopy the code

7. Start the mysql service

[root@localhost~]# service mysql start Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/xxx.pid). [root@hadoop3 ~]# CD /var/lib/mysql/ 160924 16:44:34 mysqLD_safe 160924 16:44:34 mysqLD_safe 160924 16:44:34 mysqLD_safe Starting mysqld daemon with databases from /var/lib/mysql 2016-09-24 16:44:34 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more [Note] /usr/sbin/mysqld (mysqld 5.6.26) starting as process 9816 2016-09-24 16:44:34 9816 [Note] Plugin 'FEDERATED' is disabled. ^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied) 2016-09-24 16:44:34 9816 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 2016-09-24 16:44:34 9816 [Note] InnoDB: Using atomics to ref count buffer pool pages... [root@localhost mysql]# chown mysql * [root@localhost mysql]# service mysql start Starting MySQL. SUCCESS!Copy the code

Setting boot

[root@localhost mysql]# chkconfig mysql on
Copy the code

8. Log in to mysql and change the password

[root@localhost~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.26 MySQL Community Server (GPL) Copyright (C) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help; ' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> select host,user,password from user; +-----------+------+----------+ | host | user | password | +-----------+------+----------+ | localhost | root | | | 127.0.0.1 | root | | | : : 1 | root | | | localhost | | | + -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- + 6 rows in the set (0.00 SEC)Copy the code

Changing a User password

mysql> update user set password=password("123456") where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)
Copy the code

Log out and log in again

[root@localhost~]# mysql -uroot -p Enter password:Copy the code

Set mysql to allow remote login

mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Copy the code

Open navicat for mysql and add a new connection. Enter the user name root and the password you just set. Enter the IP address of the VM

Important: be sure to enable port access for 3306

Helpful hints

Table ‘mysql.host’ does not exist because after the mysql service is newly installed, you need to initialize the database to generate tables related to permissions. Run the following command:

 /usr/bin/mysql_install_db --user=mysql
Copy the code

2. Forget the root password

Mysql/mysqld/mysqld/mysqld/mysqld/mysqld/mysqld/mysqld/mysqld Skip -grant-tables ## [root@web1 ~]# mysql > select * from '/etc/init.d/mysql'  update user set password=password("123456") where user="root"; Then refresh Flush PRIVILEGES; ERROR 1820 (HY000): You must SET PASSWORD before executing this statement SET PASSWORD = PASSWORD('Lxtd808#2018');Copy the code