Install MySQL5.6 in RPM mode under CentOS 6
1. Download the RPM package for Linux, such as the RPM package for CentOS6.7_64, as follows:
[root@mysql ~] # ll
The total dosage is 113808
-rw-. 1 root root 1434 December 13 18:47 anaconda-ks.cfg
-rw-r--r--. 1 root root 42556 December 13 18:47 install.log
-rw-r--r--. 1 root root 10033 December 13 18:45 install.log.syslog
-rw-r--r--. 1 root root 23135399 December 13 18:56 MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 root root 4586217 December 13 18:56 MySQL-devel-5.6.25-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 root root 88715219 December 13 18:56 MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm
two。 Check MySQL and related RPM packages for installation, and if any, remove (rpm-e name)
[root@mysql ~] # rpm-qa | grep-I mysql
Mysql-libs-5.1.73-5.el6_6.x86_64
[root@mysql] # rpm-ev mysql-libs-5.1.73-5.el6_6.x86_64-- nodeps
3. Install MySQL
[root@mysql] # rpm-ivh MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm
Preparing... # [100%]
1:MySQL-server # # [100%]
Warning: user mysql does not exist-using root
Warning: group mysql does not exist-using root
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
[root@mysql] # rpm-ivh MySQL-devel-5.6.25-1.linux_glibc2.5.x86_64.rpm
Preparing... # [100%]
1:MySQL-devel # # [100%]
[root@mysql] # rpm-ivh MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm
Preparing... # [100%]
1:MySQL-client # # [100%]
4. Initialize MySQL and set password
[root@mysql ~] # / usr/bin/mysql_install_db-- mysql_install_db script to generate the account and corresponding permission permission table
WARNING: The host 'mysql' could not be looked up with / usr/bin/resolveip.
This probably means that your libc libraries are not 100% compatible
. . Omit the output.
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 server
[root@mysql ~] # service mysql start
Starting MySQL. SUCCESS!
[root@mysql ~] # cat / root/.mysql_secret-- check the root account password
# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local time): 7MhtyX3aZEl9OUf8
[root@mysql] # mysql-uroot-p
Enter password:-- (copy and paste 7MhtyX3aZEl9OUf8 here)
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 2
Server version: 5.6.2
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.
Note: the appearance of mysql > indicates that everything is going well.
Mysql > SET PASSWORD = PASSWORD ('123456');-- set the password to 123456
5. Allow remote login
Mysql > use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql > select host,user,password from user
+-- +
| | host | user | password | |
+-- +
| | localhost | root | * 6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| | mysql | root | * 6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
| | 127.0.0.1 | root | * 6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
| |:: 1 | root | * 6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
+-- +
4 rows in set (0.00 sec)
Mysql > update user set password=password ('123456') where user='root'
Query OK, 3 rows affected (0.00 sec)
Rows matched: 4 Changed: 3 Warnings: 0
Mysql > update user set host='%' where user='root' and host='localhost'
Query OK, 1 row affected (0.01sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql > flush privileges
Query OK, 0 rows affected (0.00 sec)
Mysql > exit
6. Set Boot self-boot
[root@mysql ~] # chkconfig mysql on
[root@mysql ~] # chkconfig-- list | grep mysql
Mysql 0: off 1: off 2: enable 3: enable 4: enable 5: enable 6: close
7. Default installation location of MySQL
/ var/lib/mysql/ # database directory
/ usr/share/mysql # configuration file directory
/ usr/bin # related command directory
/ etc/init.d/mysql # startup script
8. Change the MySQL directory and character set
[root@mysql01 /] # cd /
[root@mysql01 /] # mkdir data # create a data directory
[root@mysql01 /] # service mysql stop
Shutting down MySQL.... [OK]
[root@mysql01 /] # mv / var/lib/mysql / data # move the entire directory / var/lib/mysql to / home/data
[root@mysql01 /] # mkdir-p / data/mysql/binarylog
[root@mysql01 /] # chown-R mysql:mysql / data/mysql
If there is no my.cnf configuration file in the / etc/ directory, please find the * .cnf file under / usr/share/mysql/, copy one of them to / etc/ and rename it to my.cnf
[root@mysql ~] # cp / usr/share/mysql/my-default.cnf / etc/my.cnf-- modify the configuration file location
Configure / etc/my.cnf file, modify the data storage path, mysql.sock path and default encoding utf-8.
[root@mysql01 /] # cat / etc/my.cnf
[client]
Password = 123456
Port = 3306
Default-character-set = utf8
[mysqld]
Port = 3306
Socket = / data/mysql/mysql.sock
Character_set_server = utf8
Character_set_client = utf8
Collation-server=utf8_general_ci
Lower_case_table_names = 1
Max_connections = 1000
Datadir = / data/mysql/
Log_bin = / data/mysql/binarylog/binlog
[mysql]
Default-character-set = utf8
Socket = / data/mysql/mysql.sock
View character set
Show variables like'% collation%'
Show variables like'% char%'
9. Restart the MySQL service
[root@mysql ~] # service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
OK is a success.