码迷,mamicode.com
首页 > 数据库 > 详细

CentOS 6.5 二进制安装MySQL 5.6

时间:2017-06-19 17:03:38      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:二进制安装mysql 5.6

CentOS 6.5 二进制安装MySQL 5.6

--------------------------------


下载MySQL5.6二进制包

mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz



安装相关依赖包

yum install libaio*

useradd mysql


安装mysql到/data/mysql/data下


tar zxvf mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz -C /data/

mv mysql-5.6.20-linux-glibc2.5-x86_64 mysql



修改mysql的各级文件夹和文件的创建者、创建组为mysql(注意语句后面有个.)


chown -R mysql.mysql /data/mysql


至此mysql已经安装完了,

但还需要初始化,初始化mysql表、test表、infomation表等。


/data/mysql/scripts/mysql_install_db --datadir=/data/mysql/data --basedir=/data/mysql --user=mysql --explicit_defaults_for_timestamp

-------------------------------------------------------------------------------------------------------------------------------------


拷贝启动脚本

cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld

 

ln -s /data/mysql/include /usr/include/mysql


echo "/data/mysql/lib" > /etc/ld.so.conf.d/mysql.conf && ldconfig -v


ln -s /data/mysql/bin/mysql /usr/bin 



修改配置文件my.cnf


cd /data/mysql

 cp my.cnf /etc/my.cnf


 vim /etc/my.cnf


[mysqld]中添加:

 

basedir = /data/mysql

datadir = /data/mysql/data

port = 3306

server_id = 1


-------------------------  


启动mySQL服务


chkconfig mysqld on

service mysqld start

  


登陆MySQL并且删除空用户

mysql


mysql> SELECT user,host,password FROM mysql.user;

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

| user | host                  | password |

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

| root | localhost             |          |

| root | localhost.localdomain |          |

| root | 127.0.0.1             |          |

| root | ::1                   |          |

|      | localhost             |          |

|      | localhost.localdomain |          |

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

6 rows in set (0.00 sec)

 

设置密码()括号里面的为密码,用户名root

mysql> UPDATE mysql.user set password = PASSWORD(‘Zykj@password‘) WHERE user = ‘root‘;


mysql> SELECT user,host,password FROM mysql.user;


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

| user | host                  | password                                  |

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

| root | localhost             | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

| root | localhost.localdomain | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

| root | 127.0.0.1             | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

| root | ::1                   | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

|      | localhost             |                                           |

|      | localhost.localdomain |                                           |

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

6 rows in set (0.00 sec)



mysql> DROP USER ‘‘@localhost;

 

mysql> FLUSH PRIVILEGES;


mysql> quit


---------------------MySQL安装完成-------------------------------


设置/修改 密码

mysql> grant all privileges on *.* to ‘root‘@‘localhost‘ identified by ‘Zykj@password‘ with grant option;

mysql> flush privileges;

















  


CentOS 6.5 二进制安装MySQL 5.6

标签:二进制安装mysql 5.6

原文地址:http://xmomo.blog.51cto.com/5994484/1939747

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!