Mysql服务器搭建
1:安装从网上下载文件的wget命令
[ ~]# yum -y install wget
2:下载mysql的repo源
[ ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
3:安装mysql-community-release-el7-5.noarch.rpm包
[ ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
4:查看下
[ ~]# ls -1 /etc/yum.repos.d/mysql-community* /etc/yum.repos.d/mysql-community.repo /etc/yum.repos.d/mysql-community-source.repo
会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
5:安装mysql
[ ~]# yum install mysql-server
6:安装完成之后,启动MySql服务
[ ~]# systemctl start mysql.service
7:为mysql的root帐户设置密码
[ ~]# mysql_secure_installation
回车,根据提示输入Y
输入2次密码,回车
根据提示一路输入Y
最后出现:Thanks for using MySQL!
MySql密码设置完成,重新启动 MySQL
8:重启
[ ~]# systemctl restart mysqld
9:为Mysqls配置远程登录
1)在本机先使用root用户登录mysql
mysql -u root -p"123456"
2)进行授权操作:
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
3)重载授权表
FLUSH PRIVILEGES;
到此可以通过navicat连接mysql
(注意:如果连接不上,要关闭防火墙:systemctl disable firewalld.service)