安装.
sudo yum -y install mysql-server (因为centOs7默认移除mysql包了 , 所以此处会有错 ,安装方式在下方)
修改配置文件 my.cnf
sudo vim /etc/my.cnf
character-set-server=utf8
default-character-set=utf8
image.png
设置 mysql 随系统启动
sudo chkconfig mysqld on
检查一下设置成功没有 , 2345都是on就ok
sudo chkconfig --list mysqld
image.png
启动mysql
sudo service mysqld start
登录到mysql
mysql -u root 第一次不用加-p
image.png
查看匿名用户
select user,host from mysql.user;
image.png
删掉匿名用户
delete from mysql.user where user='';
image.png
防火墙添加3306端口
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
数据库中插入用户
insert into mysql.user(Host,User,Password) values("localhost","linlindiy","linlindiy")
image.png
创建数据库
create database `partner` default character set utf8 collate utf8_general_ci;
image.png
查看权限 \G表示格式化
select * from mysql.user \G
image.png
添加权限
grant all privileges on partner.* to linlindiy@'%' identified by 'linlindiy' with grant option;
image.png
需要刷新权限
mysql> flush privileges;
修改root密码
mysql> set password for root@localhost=password('mysql');
mysql> set password for root@127.0.0.1=password('mysql');
dql ,dml ,ddl,dcl 的意思
- dql
- select
- dml
- insert
- update
- delete
- ddl
- create table
- create view
- dcl
- grant
CentOs 7 安装mysql方式
CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除了,用mariadb代替了
- 1、方法一:安装mariadb
yum install mariadb-server mariadb
- 2、官网下载安装mysql-server
1. wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
2. rpm -ivh mysql57-community-release-el7-11.noarch.rpm
3. yum update
4. yum install -y mysql-server
网友评论