MySQL学习笔记--安装配置(RPM)
作者:互联网
1. 下载MySQL 5.6
下载页面:http://dev.mysql.com/downloads/mysql/
此处选择“Red Hat Enterprise Linux 6 / Oracle Linux 6 (x86, 64-bit), RPMBundle”下载
注:
MySQL-5.6.28-1.el6.x86_64.rpm-bundle.tar包含了MySQL需要安装的所有包
2.检查安装
在安装MySQL之前,先检查Linux系统中是否已经安装了一个MySQL,如果已经安装先卸载,不然会导致安装新的MySQL失败。
--查看系统之前是否已安装MySQL
# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
--删除这个老版本,用root用户执行下面语句
# rpm -e --nodepsmysql-libs-5.1.47-4.el6.i686
或是在安装MySQL-shared-compat-5.6.28-1.el6.x86_64.rpm包时也能删除这个lib包
# rpm -UvhMySQL-shared-compat-5.6.28-1.el6.x86_64.rpm
--删除一些MySQL相关目录
rm -rf /var/lib/mysql*
rm -rf /usr/share/mysql*
mysql安装软件在/usr/share/mysql目录下
Mysql数据库创建在/var/lib/mysql目录下
mv /etc/my.cnf my.cnf.rpmsave
mv /var/log/mysqld.log/var/log/mysqld.log.rpmsave
3. 解压tar包
# tar -xvfMySQL-5.6.15-1.el6.i686.rpm-bundle.tar
MySQL-shared-compat-5.6.28-1.el6.x86_64.rpm # MySQL的RHEL兼容包,包括服务端动态链接库libmysqlclient文件
MySQL-embedded-5.6.28-1.el6.x86_64.rpm # 嵌入式的MySQL服务端
MySQL-client-5.6.28-1.el6.x86_64.rpm #MySQL客户端程序
MySQL-server-5.6.28-1.el6.x86_64.rpm #MySQL服务端程序
MySQL-test-5.6.28-1.el6.x86_64.rpm #MySQL测试套件
MySQL-devel-5.6.28-1.el6.x86_64.rpm #MySQL的库和头文件
MySQL-shared-5.6.28-1.el6.x86_64.rpm #MySQL的共享库(libmysqlclient.so*)
4. 以RPM方式安装MySQL
yum installMySQL-shared-compat-5.6.28-1.el6.x86_64.rpm
# 必须先安装这个兼容包,然后才能安装server和client,否则安装时会出错
yum installMySQL-client-5.6.28-1.el6.x86_64.rpm
yum installMySQL-server-5.6.28-1.el6.x86_64.rpm
yum installMySQL-devel-5.6.28-1.el6.x86_64.rpm
yum installMySQL-shared-5.6.28-1.el6.x86_64.rpm
yum installMySQL-embedded-5.6.28-1.el6.x86_64.rpm
yum installMySQL-test-5.6.28-1.el6.x86_64.rpm
或是:
rpm -ivhMySQL-server-5.6.28-1.el6.x86_64.rpm
rpm -ivhMySQL-client-5.6.28-1.el6.x86_64.rpm
5. 配置MySQL登录密码
从MySQL5.6版本开始rpm安装完成后,root用户不再是空密码,会生成一个随机密码,第一次登录后要首先修改root密码,否则MySQL不能进行任何操作.
--获取MySQL安装时生成的随机密码
# cat /root/.mysql_secret
--启动MySQL服务
# service mysql start
--进入MySQL,使用之前获取的随机密码
# mysql -uroot -p
-在MySQL命令行中设置root账户的密码为password
SQL> SET PASSWORD FOR 'root'@'localhost'= PASSWORD('password');
--退出重新启动MySQL服务
quit
# service mysql restart
遇到的问题:
1.找不到mysql.sock文件
在登录时出现ERROR 2002 (HY000)错误
[root@host8 ~]# mysql
ERROR 2002 (HY000): Can't connect to localMySQL server through socket '/data/mysqldata/3306/mysql.sock' (2)
原因:
由于之前服务器上源码安装过mysql,cmake编译时指定过mysql.sock位置
见http://blog.csdn.net/lichangzai/article/details/48974721中“执行cmake生成编译配置文件”
解决:
启动mysql服务后查看mysql.sock的默认位置
[root@host8 ~]# find / -name"mysql.sock" -print
/var/lib/mysql/mysql.sock
然后在.bash_profile添加环境变量MYSQL_UNIX_PORT
[root@host8 ~]# vi .bash_profile
exportMYSQL_UNIX_PORT=/var/lib/mysql/mysql.sock
再登录时不会出错误
[root@host8 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.28
Copyright (c) 2000, 2015, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
mysql>
2.配置文件my.cnf的位置
rpm安装后,启动mysql时默认配置文件为/etc/my.cnf
如果没有可手动创建,可从/usr/local/mysql/my.cnf 位置拷贝一份。
标签:5.6,--,el6,RPM,64,mysql,MySQL,rpm 来源: https://blog.csdn.net/lgxzzz/article/details/122096576