CentOS7安装配置mysql

时间:2016-09-22 00:28来源:blog.csdn.net 作者:bedisdover 举报 点击:

安装

1. CentOS7的默认软件源中没有mysql,需先添加mysql的repo源

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

2.使用rpm安装刚刚下载好的软件包

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

3. yum安装

yum install mysql-server

4.启动mysql

systemctl start mysql

配置

1. 修改root密码

mysqladmin -u root password "newpassword"

2. 本地登录

   mysql -u root -p

若出现报错

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

请参考 [解决]ERROR 2002 (HY000): Can’t connect to local MySQL server

3.添加远程用户

GRANT ALL PRIVILEGES ON *.* for 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

4. 开放3306端口

/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
------分隔线----------------------------
发表评论
为了和诣的生活,我关闭了评论页面,请大家到QQ群里交流吧:348944156,也欢迎关注本站微信公众号:centoscn
栏目分类