1. 安装
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
2.启动服务
systemctl start mysqld
3.默认用户(root)无密码登陆
mysql -u root -p
4.创建个人用户,数据库,密码
create database zhanglinpengdb;
create user 'zhanglinpeng'@'localhost' identified by 'zhanglinpeng'; //最后一个字段为密码,注意
grant all on zhanglinpengdb.* to 'zhanglinpeng' identified by 'zhanglinpeng'; //授权
5.退出mysql
exit;
6,进入数据库
use zhanglinpengdb;
7.重置root用户的密码
sudo systemctl stop mysqld
sudo mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user SET PASSWORD=PASSWORD("password") WHERE USER='root';
flush privileges;
exit;
systemctl start mysqld
8,mysql 5.7安装在windows上,修改密码
以管理员身份运行cmd
在cmd命令行下,运行net stop mysql
转到mysql目录的bin目录下,运行命令mysqld --skip-grant-tables
新开启一个cmd。运行mysql -u root -p
进入到mysql 中后,use mysql ;
update mysql.user set authentication_string=password('123456') where user='root' and Host='localhost';
flush privileges;
exit;
关闭所有mysql进程后,重启Mysql: net start mysql
9.导入数据库
常用source 命令
进入mysql数据库控制台,
如mysql -u root -p
mysql>use 数据库
然后使用source命令,后面参数为脚本文件(如这里用到的.sql)
mysql>source d:wcnc_db.sql