cetos7安装mysql

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum install mysql-community-server

成功安装之后重启mysql服务

service mysqld restart

初次安装mysql是root账户是没有密码的
设置密码的方法

mysql -uroot

mysql> set password for ‘root’@‘localhost’ = password('root');
mysql> exit

create table user(
id INT NOT NULL AUTO_INCREMENT,
email VARCHAR(100) NOT NULL,
username VARCHAR(100) NOT NULL,
password VARCHAR(40) NOT NULL,
createtime DATE,
PRIMARY KEY ( id )
);
create table note(
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(40) NOT NULL,
author VARCHAR(100) NOT NULL,
tag VARCHAR(2) NOT NULL,
content VARCHAR(400) NOT NULL,
createtime DATE,
PRIMARY KEY ( id )
);

你可能感兴趣的:(cetos7安装mysql)