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
Step5:查看mysql默认密码
vi /var/log/mysqld.log
mysql -u root -p 回车输入密码
设置mysql密码策略
set global validate_password_policy=0;
查看密码最小长度
select @@validate_password_length;
设置密码最小长度
set global validate_password_length=1
查询当前用户
select user();
修改密码
ALTER USER USER() IDENTIFIED BY '123456';
验证validate_password插件
SHOW VARIABLES LIKE 'validate_password%';
允许远程root登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
刷新权限配置
flush privileges;
Step8: mysql安全设置
命令:
# mysql_secure_installation