centos6.3 安装mysql5.6

1、去官网下载MySQL,https://dev.mysql.com/downloads/mysql/5.6.html#downloads

选择redhat6 64bit

  下载rpm bundle

2、将文件拷贝到centos,解压 tar -xvf MySQL-5.6.39-1.el6.x86_64.rpm-bundle.tar

3、检查是否已安装mysql,rpm -qa|grep mysql ,如果有,运行 rpm -e 卸载

4、安装mysql  

  rpm -ivh MySQL-client-5.6.39-1.el6.x86_64.rpm

  rpm -ivh MySQL-devel-5.6.39-1.el6.x86_64.rpm

  rpm -ivh MySQL-server-5.6.39-1.el6.x86_64.rpm

  安装MySQL-server-5.6.39-1.el6.x86_64.rpm的时候可能会报错,缺少包

  这都是因为缺少依赖的相关包造成的,解决办法是通过yum直接安装这些依赖包。 
  yum -y install libaio 
  yum -y install numactl

5、将配置文件拷贝到/etc目录下,cp /usr/share/mysql/my-default.cnf  /etc/my.cnf

  修改配置文件 vi /etc/my.cnf 在[mysqld]下面加上

  skip-grant-tables

  否则登录时会报 错:

  [root@localhost ~]# mysql -u root -p
  Enter password:
  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

6、启动mysql  service mysql start

7、登录mysql,这一步不需要输密码 直接输mysql 即可,修改root密码

mysql> update mysql.user set authentication_string=password('root') 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)

mysql> exit
Bye

vi /etc/my.cnf 将skip-grant-tables注释掉

然后重启mysql 

service mysql restart

8、登录mysql 

mysql -uroot -p

posted @ 2018-04-02 11:06  Carousel  阅读(183)  评论(0编辑  收藏  举报