Linux下MySQL-5.6.26 RPM包安装

时间:2022-03-12 10:07:50

1.前言

       

本文测试环境:

  • CentOS release 6.4(Linux version 2.6.32-358.el6.x86_64)

  • MySQL-5.6.26 RPM包下载地址:http://dev.mysql.com/downloads/mysql/,相关的文档参详:http://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
  • MySQL社区版对应的RPM包如下:

Package Name

Summary

mysql-community-server

Database server and related tools

mysql-community-client

MySQL client applications and tools

mysql-community-common

Common files for server and client libraries

mysql-community-devel

Development header files and libraries for MySQL database client applications

mysql-community-libs

Shared libraries for MySQL database client applications

mysql-community-libs-compat

Shared compatibility libraries for previous MySQL installations

mysql-community-embedded

MySQL embedded library

mysql-community-embedded-devel

Development header files and libraries for MySQL as an embeddable library

mysql-community-test

Test suite for the MySQL server

2.安装前准备

1)检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpme名称)

[root@nn ~]# rpm -qa | grep -i mysql

[root@nn ~]# yum -y remove mysql-libs*

2)下载Linux对应的RPM包,如:CentOS6.4_64对应的RPM包,本文已在官网下载,这里就不详叙了。

3)MySQL默认安装路径

Directory

Contents of Directory

/usr/bin

Client programs and scripts

/usr/sbin

The mysqld server

/var/lib/mysql

Log files, databases

/usr/share/info

Manual in Info format

/usr/share/man

Unix manual pages

/usr/include/mysql

Include (header) files

/usr/lib/mysql

Libraries

/usr/share/mysql

Miscellaneous support files, including error messages,

character set files, sample configuration files, SQL for database installation

/usr/share/sql-bench

Benchmarks


3.安装MySQL

[root@nn ~]# cd /home/MySql/MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle/

[root@nn MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle]# rpm -ivh MySQL-server-5.6.26-1.linux_glibc2.5.x86_64.rpm


Linux下MySQL-5.6.26 RPM包安装

[root@nn MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle]# rpm -ivh MySQL-client-5.6.26-1.linux_glibc2.5.x86_64.rpm

Linux下MySQL-5.6.26 RPM包安装

4.初始化MySQL及密码

[root@nn ~]# service mysql start

[root@nn ~]# more /root/.mysql_secret

Linux下MySQL-5.6.26 RPM包安装

[root@nn ~]# mysql -u root -p

mysql> set PASSWORD=PASSWORD('123456');

Linux下MySQL-5.6.26 RPM包安装

5.允许远程登陆

mysql> use mysql;

mysql> select host,user,password from user;

mysql> update user set password=password('123456') where user='root';

mysql> update user set host='%' where user='root' and host='localhost';

mysql> flush privileges;

Linux下MySQL-5.6.26 RPM包安装

6. 修改字符集和数据存储路径

配置/etc/my.cnf文件,修改数据存放路径、mysql.sock路径以及默认编码utf-8

[root@nn ~]# cp /usr/my.cnf /etc/my.cnf
Linux下MySQL-5.6.26 RPM包安装

7.设置开机自启动

[root@nn ~]# chkconfig mysql on

[root@nn ~]# chkconfig --list | grep mysql
8.允许远程登录

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT option;

         该SQL的作用是将所有的用户名,都设置能远程访问该mysql中所有的表,如果不想都放开,可以根据这个规则,来设置.grant权限1,权限2,…权限n on数据库名.表名to用户名@用户地址identified by‘口令’。