centos 安装mysql

查找以前是否装有MySQL

命令:rpm -qa | grep -i mysql 

 

•下载
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

 

 

 

安装包
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

•安装Mysql

 

sudo yum install mysql-server


•更改权限
sudo chown -R mysql:mysql /var/lib/mysql


sudo service mysqld start

 

创建数据库用户:

 

CREATE USER 'xiaowu'@'<127.0.0.1>' IDENTIFIED BY '123456';

CREATE USER 'xiaowu'@'127.0.0.1' IDENTIFIED BY '123456';
CREATE USER 'xiaowu'@'%' IDENTIFIED BY '123456';
CREATE USER 'xiaowu'@'::1' IDENTIFIED BY '123456';

 

授予用户所有权限,[*.*]表示所有数据库 [to xiaowu] 表示用户是xiaowu


grant all privileges on *.* to xiaowu ;

flush privileges;

 

 

mysql访问配置添加3306端口:

iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
service iptables save
service iptables restart

 

posted @ 2022-04-04 09:48  .net&new  阅读(58)  评论(0编辑  收藏  举报