Step1: 检测系统是否自带安装mysql
# yum list installed | grep mysql
Step2: 删除系统自带的mysql及其依赖命令:
# yum -y remove mysql-libs.x86_64
Step3: 给CentOS添加rpm源,并且选择较新的源命令:
# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm# yum localinstall mysql-community-release-el6-5.noarch.rpm# yum repolist all | grep mysql# yum-config-manager --disable mysql55-community# yum-config-manager --disable mysql56-community# yum-config-manager --enable mysql57-community-dmr# yum repolist enabled | grep mysql
Step4:安装mysql 服务器命令:
# yum install mysql-community-server
Step5: 启动mysql命令:
# service mysqld start
Step6: 查看mysql是否自启动,并且设置开启自启动命令:
# chkconfig --list | grep mysqld# chkconfig mysqld on
Step7:设置防火墙
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
/etc/init.d/iptables save
chkconfig mysqld on
Step8:查看root用户密码
sudo grep 'temporary password' /var/log/mysqld.log
Step9:使用root登陆
mysql -u root -p 'password'
Step10:修改密码复杂度
set global validate_password_policy=0;
Step11:修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Step12:设置mysql root 远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
网友评论