mysql linux安裝(二)——rpm方式 博客分类: mysql
1.去http://mirrors.sohu.com/mysql/下载mysql的rpm包:
MySQL-server-5.6.35-1.el6.x86_64
MySQL-client-5.6.35-1.el6.x86_64
MySQL-devel-5.6.35-1.el6.x86_64
2.执行安装命令(注意安装之前要保证本机没有已安装的mysql):
rpm -ivh MySQL-server-5.6.35-1.el6.x86_64
如果报错:
[root@bjyf-59-46 qiangge]# rpm -ivh MySQL-server-5.6.35-1.el6.x86_64.rpm
warning: MySQL-server-5.6.35-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
/bin/sh is needed by MySQL-server-5.6.35-1.el6.x86_64
/usr/bin/perl is needed by MySQL-server-5.6.35-1.el6.x86_64
chkconfig is needed by MySQL-server-5.6.35-1.el6.x86_64
可以执行以下强制命令:
rpm -ivh MySQL-server-5.6.35-1.el6.x86_64.rpm --nodeps --force
继续安装client和devel的rpm安装包。
3. 初始化MySQL及设置密码
#安装mysql
/usr/bin/mysql_install_db
#启动mysql服务
service mysql start
#查看root账号密码
cat /root/.mysql_secret
# The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): qKTaFZnl
(如果未修改过root用户密码,默认为随机密码KTaFZnl)
#然后用随机密码登录root
mysql -uroot –pqKTaFZnl
#然后修改root用户密码为123456
SET PASSWORD = PASSWORD('123456');
#退出,用新密码登录
mysql -uroot -p123456
4. 修改允许远程登录
cd /usr/bin
./mysql -uroot -p123456
use 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 | +-----------------------+------+-------------------------------------------+
#修改root用户的密码
update user set password=password('123456') where user='root';
#修改root用户允许远程登录的权限
update user set host='%' where user='root' and host='localhost';
#使修改生效
flush privileges; ---意为重新加载权限表,也可以通过重启mysql服务来实现。
5.设置开机自启动
chkconfig mysql on
查看结果:
chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
*安装过程中可能会出现的错误:
1.Installing MySQL system tables.../usr/sbin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
解决方法:yum install -y numactl.x86_64
2.ERROR! The server quit without updating PID file (/var/lib/mysql/bjyf-guweiqiang-59-48.pid).
解决方法:
linux 安装mysql rpm参考:
http://blog.csdn.net/leshami/article/details/23826753
http://www.cnblogs.com/xs104/p/4589041.htm
http://blog.csdn.net/liumm0000/article/details/18841197
以下为rpm方式安装mysql的卸载方法:
1、 检查是否安装了MySQL组件
rpm -qa | grep -i mysql
显示的即为已安装的mysql组件列表。
调用 rpm -e <包的名字> 删除特定rpm包
如果遇到依赖,无法删除,使用 rpm -e --nodeps <包的名字> 不检查依赖,直接删除rpm包。
2、卸载之前关闭mysql服务:
service mysqld status
如果显示running,则表示有mysql服务在运行。
3. 执行命令:find / -name mysql
列出的就是含有mysql目录的所有路径,然后执行删除目录命令:
rm -rf /usr/local/mysql
检查是否已删除干净:whereis mysql
如果为空,就表示已全部删除干净。
4. 删除mysql用户和用户组
userdel mysql
groupdel mysql
5. 删除mysql配置文件:
rm -rf /etc/my.cnf
最后检查是否还有未卸载的mysql组件:
rpm -qa | grep -i mysql
参考:
http://blog.csdn.net/leshami/article/details/25068945
http://www.cnblogs.com/kerrycode/p/4364465.html