[root@localhost local]# wget https://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm2.安装下载的rpm包
[root@localhost local]# rpm mysql57-community-release-el7-9.noarch.rpm3.yum安装mysql
[root@localhost local]# yum install mysql-server4.启动mysql
[root@localhost local]# service mysqld start*小笔记*mysql 启动、重启、停止1.第一种systemctl start mysqld.servicesystemctl restart mysqld.servicesystemctl stop mysqld.service2.第二种service mysqld startservice mysqld restartservice mysqld stop修改初始root密码mysql5.7.6以后的版本在启动数据库的时候,会生成密码放到日志文件里,可从从日志获取:
或者
[root@localhost local]# systemctl start mysqld.service
[root@localhost local]# cat /var/log/mysqld.log | grep 'password'日志的第一条最后那串字符就是初始密码,这里是 lRym!ofXx6/r
2017-02-08T10:48:53.368640Z 1 [Note] A temporary password is generated for root@localhost: lRym!ofXx6/r
[root@localhost local]# mysql -uroot -p登录后输入sql语句发现
Enter password:
mysql> show databases;意思是要修改初始密码,修改方法如下(这里密码是Xm123456@):
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password='Xm123456@';用新密码重新登录即可,测试可以执行sql语句了,到此修改初始root密码完成。
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |