- Mysql5.7.11安装 - yum方式:
1、mysql官方网站下载mysql yum repo文件(rpm文件),安装后在系统/etc/yum.repo.d目录多出2个文件
2、yum search mysql
3、yum install mysql-community-server.x86_64 (mysql社区版)
- 新安装mysql后无root密码无法登陆问题:
1.systemctl stop mysqld.service 关闭mysql服务
2.vi /etc/my.cnf 在mysqld下面添加 skip-grant-tables,重启mysql服务systemctl start mysqld.service
3.登录mysql,mysql -u root 不用密码直接回车
4.输入 update user set authentication_string=password(‘密码‘) where User=‘root‘ and Host=‘localhost‘;
5.成功后输入 flush privileges;
6.exit退出mysql
7.vi /etc/my.cnf 把 skip-grant-tables 一句删除保存退出重启mysql服务
8.重新登录mysql,mysql -u root -p回车 输入你刚才填写的密码
9.登录成功后你的操作可能会出现如下两句
Your password does not satisfy the current policy requirements
You must reset your password using ALTER USER statement before executing this statement.
进入mysql执行命令: alter user ‘root‘@‘localhost‘ identified by ‘password‘
=====================
Show databases;
Create dbname;
Use dbname;
Set names utf8;
Mysql -u root -p dbname<script.sql;