Linux上部署mysql数据库:
第一步:看看系统中有没有自带有mysql的东西,有就先删除掉。
使用命令查看:find / -name mysql
删除rm -rf 上边查找到的路径,多个路径用空格隔开
第二步:开始安装
rpm -Uvh https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
yum --enablerepo=mysql80-community install mysql-community-server
出现是否确认下载:输入y
出现Complete 完成!
输入service mysqld start
查看状态
接下来,mysql为我们创建的默认密码,首次的登陆和配置mysql时需要用到。
grep "A temporary password" /var/log/mysqld.log
出现的密码需要备份记住;
得到mysql的默认密码之后,我们开始配置mysql:
mysql_secure_installation
输入初始密码,并输入新密码,若出现Your password does not satisfy the current policy requirements,
输入SHOW VARIABLES LIKE 'validate_password%';
查看密码策略,出现
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
那么依次输入命令:
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
重新输入mysql> SHOW VARIABLES LIKE 'validate_password%';
出现
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 6 |
| validate_password.mixed_case_count | 0 |
| validate_password.number_count | 1 |
| validate_password.policy | LOW |
| validate_password.special_char_count | 0 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)
在修改密码:ALTER user 'root'@'localhost' IDENTIFIED BY '新密码';
同时输入flush privileges;
出现Do you wish to continue with the password provided?可以选择Y,但需要记住初始的密码,
出现Change the password for root,选择y,按照上述命令操作即可,
当出现Disallow root login remotely?(Pressy|Y for Yes,any other key for No)时输入n,这句的意思询问是否禁止远程登录。