Linux下安装mysql
source link: https://blog.51cto.com/zhanjq/5665889
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
下载
进入 http://dev.mysql.com/downloads/mysql/,通过下拉框可以下载对应系统环境的MySQL
可以通过选中 Archives下载历史版本的MySQL。
或者使用wget下载:
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.22-1.el6.i686.rpm-bundle.tar
安装
检测是否已经安装了mysql
rpm -qa | grep mysql
如果已经安装了,将其卸载,如:
rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
安装mysql
创建安装目录并解压
mkdir /usr/local/src/mysql
cd /usr/local/src/mysql
tar -xvf MySQL-5.6.22-1.el6.i686.rpm-bundle.tar
安装server
rpm -ivh MySQL-server-5.6.22-1.el6.i686.rpm
出错:error:Failed dependencies,缺少依赖
安装依赖:
yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6
Error : Multilib version problems found. This often means that the root
cause is something else and multilib version checking is just
Protected multilib versions: libstdc+±4.4.7-11.e16.i686 != libstdc+±4.4.7-4.
e16.x86_64
需要升级libstdc+±4.4.7-4.el6.x86_64
yum update libstdc++-4.4.7-4.el6.x86_64
安装client
rpm -ivh MySQL-server-5.6.22-1.el6.i686.rpm
报错也是缺少依赖
安装依赖:
yum -y install libncurses.so.5 libtinfo.so.5
查询mysq服务运行状态
service mysql status
服务未启动。
启动mysql服务
service mysql start
使用root账号登录mysql
提示:
ERROR 1045(28000): Access denied for user 'root ' @'localhost' (using password: No)
在安装mysql server时有句提示:
注意:这个密码是不安全的,所有需要修改初始密码。
使用密码登录mysql账号:
mysql -uroot -p
修改root密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'youPassword';
系统启动时自动启动mysql服务
加入到系统服务:
chkconfig --add mysql
自动启动:
chkconfig mysql on
查询列表:
chkconfig
说明:Linux chkconfig 命令用于检查,设置系统的各种服务。
这是Red Hat公司遵循GPL规则所开发的程序,它可查询操作系统在每一个执行等级中会执行哪些系统服务,其中包括各类常驻服务。
开启远程访问
mysql -uroot –p123456
设置远程访问(使用root密码):
grant all privileges on *.* to 'root' @'%' identified by '123456';
flush privileges;
防火墙打开3306端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK