最后的截图:
4 启动数据库:
[root@typecodes ~]# systemctl start mysqld.service
然后使用命令systemctl status mysqld.service查看MySQL数据库启动后的服务状态:
5 获取初始密码
使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码:
#######从mysql进程日志中获取root用户的初始密码:ra%yk7urCBIh [root@typecodes ~]# grep "password" /var/log/mysqld.log 2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh 2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin 'validate_password' 2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin 'sha256_password' 2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin 'mysql_native_password'
6 修改root用户密码
使用小节5中获取的root用户的初始密码,然后进行修改:
set global validate_password_policy =0;//默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
set global validate_password_length=4;//指定了密码中数据的长度 alter user root@localhost identified by 'crow';//修改密码
增加远程访问权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'crow' WITH GRANT OPTION; FLUSH PRIVILEGES;
退出mysql,然后重启服务
systemctl restart mysqld
防火墙打开3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重启防火墙
firewall-cmd --reload [root@typecodes ~]# mysql -uroot -p Enter password: #######输入默认的root密码后回车 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.10 Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
7 安装完毕
至此,使用在CentOS7中使用YUM方法安装MySQL5.7.10数据库完毕。如下所示,可以使用新的root密码登陆MySQL了。
[root@typecodes ~]# mysql -uroot -ppassword mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.10 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show databases; +--------------------+ (北联网教程,专业提供视频软件下载)
第1页 第2页 第3页 第4页 第5页 第6页 第7页 第8页 第9页 第10页 第11页 第12页 第13页 第14页 第15页 第16页 第17页 第18页 第19页 第20页 第21页 第22页 第23页 第24页 第25页 第26页 第27页 第28页 第29页……