1.在centos7上安装mysql,采用rpm进行安装
1.1查看系统mysql的安装情况
# rpm -qa | grep mysql // 这个命令就会查看该操作系统上是否已经安装了mysql数据库
如果系统有安装,那可以选择进行卸载
[root@localhost ~]# rpm -e mysql // 普通删除模式
[root@localhost ~]# rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除</span>
1.2下载地址 http://dev.mysql.com/downloads/mysql/
选择第一个下载并解压。使用WinSCP登陆到虚拟机,将rpm文件拷贝到centOS 下的/usr/local/mysql下
在本次安装中用到了如下rpm文件,安装顺序如下
mysql-community-common-5.7.13-1.el7.x86_64.rpm
mysql-community-libs-5.7.13-1.el7.x86_64.rpm
mysql-community-devel-5.7.13-1.el7.x86_64.rpm
mysql-community-client-5.7.13-1.el7.x86_64.rpm
mysql-community-server-5.7.13-1.el7.x86_64.rpm
注意安装顺序,否则会报依赖性错误
命令:
rpm -ivh mysql-community-common-5.7.13-1.el7.x86_64.rpm
安装后启动mysql
service mysqld start
查看mysql运行状态
service mysqld status
查看mysql运行
netstat -anp|grep 3306
重启mysql
service mysqld restart
停止mysql
service mysqld stop
2.在centos7上安装mysql后登陆mysql
> mysql -uroot -p
Enter password:
输入密码后出现错误
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
原因是密码不正确,为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,如果安装的是RPM包,则默认是/var/log/mysqld.log
在Xshell中输入
[root@localhost ~]#sudo grep 'temporary password' /var/log/mysqld.log
2016-07-18T13:05:55.127511Z 1 [Note] A temporary password is generated for root@localhost: mG8%E;mB3ykC
mG8%E;mB3ykC即为root的密码
用这个密码登陆到mysql,并修改密码,若密码比较简单,如‘123456’
会出现错误
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
密码不符合要求,更改密码策略,降低密码的验证标准
--更改密码策略为LOW 并更改密码长度
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file | |
| validate_password_length | 4 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
6 rows in set (0.31 sec)
设置后修改密码
[root@localhost ~]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
http://blog.csdn.net/maxsky/article/details/51171474
解决 MySQL 5.7 中 Your password does not satisfy the current policy requirements. 问题
http://blog.itpub.net/26506993/viewspace-2062622
MySQL 5.7 密码安全策略简介