Centos安装MySql5.5(yum安装),支持Centos6.x 7.x(64位)
1、卸载残留环境
rpm -qa | grep mysql
rpm -qa | grep mariadb
rpm -e --nodeps #上边命令查询的结果
2、安装rpm源
rpm -ivh http://repo.mysql.com/yum/mysql-5.5-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
修改/etc/yum.repos.d/mysql-community.repo文件,将5.5的enabled改为1,5.6的enabled改为0
不改安装的是5.6版本
3、安装并初始化
yum install -y mysql-community-client mysql-community-devel mysql-community-server
因为是国外的链接,可能有些慢,建议白天安装
初始化
service mysqld start
4、设置自启动
chkconfig mysqld on
5、修改root账号密码
/usr/bin/mysqladmin -u root password '新密码'
6、设置允许远程访问
登录
mysql -u root -p
允许远程访问
grant all privileges on *.* to root@"%" identified by "新密码" with grant option;
FLUSH PRIVILEGES;
7、相关命令
启动:service mysqld start
停止:service mysqld stop
重启:service mysqld restart
状态:service mysqld status