首页 > 代码库 > centos6.5 rpm安装mysql5.6.19
centos6.5 rpm安装mysql5.6.19
1,检查MySQL及相关RPM包,是否安装,如果有安装,则移除。
rpm -qa | grep -i mysql
yum -y remove mysql-libs*
2,根据系统下载RPM包,我下载的MySQL-5.6.19-1.el6.i686.rpm-bundle.tar
解压压缩包,依次安装:
rpm -ivh MySQL-server-5.6.19-1.el6.i686.rpm
rpm -ivh MySQL-devel-5.6.19-1.el6.i686.rpm
rpm -ivh MySQL-client-5.6.19-1.el6.i686.rpm
如果需要安装apache2+php5+mysql需要安装
MySQL-embedded-5.6.19-1.el6.i686.rpm
MySQL-shared-5.6.19-1.el6.i686.rpm
MySQL-shared-compat-5.6.19-1.el6.i686.rpm
不然编译PHP关联mysql时会一直报错:
configure: error: mysql configure failed. Please check config.log for more information.
修改配置文件:
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
3,初始化mysql及设置密码
/usr/bin/mysql_install_db
service mysql start
cat /root/.mysql_secret #查看root帐号初始密码
mysql -uroot -ppassword #"password"是上面命令查看的密码
登录成功后修改密码:
mysql>SET PASSWORD =PASSWORD(‘123456‘);
mysql>exit;
4,允许远程登录
mysql>use mysql;
mysql>select host,usr,password from user;
mysql>update user set password=password(‘123456‘) where user=‘root‘;
mysql>update user set host=‘%‘ where user=‘root‘ and host=‘localshot‘;#允许所有用户远程链接
mysql>flush privileges;
mysql>exit
5,设置开机自动启动
chkconfig mysql on
chkconfig --list | grep mysql #查看开机启动状态
6,修改/etc/my.cnf文件
增加:
[client]
password=123456
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld]
port = 3306
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci
lower_case_table_names=1
socket=/var/lib/mysql/mysql.sock
max_connections=1000
在最后行sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES后面加
[mysql]
default-character-set=utf8
刚开始我将[mysql]及编码放在sql_mode=......前面运行数据库报错
mysql: unknown variable ‘sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES‘
放在sql_mode=..后面数据库运行正常。
7,查看字符集
show variables like ‘character%‘;
show variables like ‘char%‘;
8,mysql默认安装位置
查看命令:whereis mysql
/var/lib/mysql/ #数据库目录
/usr/share/mysql #配置文件目录
/usr/bin #相关命令目录
/etc/init.d/mysql #启动脚本
/usr/include/mysql #mysql头文件位置
9,最好关闭防火墙,SeLinux
service iptables stop
chkconfig iptables off
修改/etc/selinux/config
#SELINUX=enforcing #去掉
#SELINUXTYPE=targeted #去掉
SELINUX=disabled #增加