centos7 RPM方式安装MySQL5.6

a) 查看centos版本 
  cat /etc/redhat-release 
b) 卸载MariaDB (centos7默认自带)
  查看当前安装的mariadb包: rpm -qa | grep mariadb 
  强制卸载: rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64 
c) 查看是否已经安装了MySQL 
  rpm -qa | grep -i mysql

  find / -name mysql

删除分散mysql文件 
 find / -name mysql / # whereis mysql 
 删除配置文档 
 rm -rf /etc/my.cnf 
 再次查找机器是否安装mysql 
rpm -qa|grep -i mysql

d) 安装MySQL

cd /data/soft/MySQL-5.6.36-1.el7.x86_64.rpm-bundle
ls
MySQL-client-5.6.36-1.el7.x86_64.rpm MySQL-server-5.6.36-1.el7.x86_64.rpm
MySQL-devel-5.6.36-1.el7.x86_64.rpm


rpm -ivh MySQL-server-5.6.36-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.6.36-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.36-1.el7.x86_64.rpm

或者:rpm -ivh MySQL-*.rpm

#修改配置文件位置
cp /usr/share/mysql/my-default.cnf /etc/my.cnf

e)初始化MySQL及设置密码

 /usr/bin/mysql_install_db

 service mysql start

 cat /root/.mysql_secret  #查看root账号密码

 # The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): qKTaFZnl

 mysql -u root –pqKTaFZnl

 mysql> SET PASSWORD = PASSWORD('123456');    #设置密码为123456

 mysql> exit

 

 mysql -uroot -p123456

f)远程登陆用户设置

mysql> use mysql;

mysql> select host,user,password from user;

+-----------------------+------+-------------------------------------------+

| host                  | user | password                                  |

+-----------------------+------+-------------------------------------------+

| localhost             | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| localhost.localdomain | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 |

| 127.0.0.1             | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 |

| ::1                   | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 |

+-----------------------+------+-------------------------------------------+

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

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

mysql> flush privileges;

 

mysql> exit

g)设置开机自启动

 chkconfig mysql on

 chkconfig --list | grep mysql

 

 mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

h)修改字符集和数据存储路径

配置/etc/my.cnf文件,修改数据存放路径

character_set_server=utf8  

character_set_client=utf8  

collation-server=utf8_general_ci  

lower_case_table_names=1  

max_connections=3000

event_scheduler=ON 

[mysql]  

default-character-set = utf8

参考:

http://www.centoscn.com/mysql/2015/0624/5729.html

http://www.2cto.com/kf/201609/550880.html

 

常见错误:

sql执行错误#1018:can't read dir of './performance_schema/'(errno:13-permission denied)
ls -ld /var/lib/mysql/performance_schema
chown -R mysql:mysql /var/lib/mysql/performance_schema

 

http://blog.csdn.net/thinkpadshi/article/details/48650921

posted @ 2017-07-10 15:41  Tomson Qiang  阅读(7453)  评论(0编辑  收藏  举报