linux安装mysql数据库
我的linux版本是 CentOS 7.2
1,首先执行以下命令:
# 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('mypasswd');
mysql> exit
|
搞定!
2,需要数据库允许远程访问,因为为了安全mysql安装默认是禁止的
进入mysql命令行
mysql -u用户名-p用户密码
添加远程用户admin密码为password
grant all privileges on *.* to [email protected] identified by 'password'
with grant option
grant all privileges on *.* to [email protected]"%" identified by 'password'
with grant option
3,云服务器需要开启3306端口号
开启防火墙 :systemctl start firewalld.service
查看所有已开启的端口号 :firewall-cmd --zone=public --list-ports
添加端口号 :firewall-cmd --zone=public --add-port=3306/tcp --permanent
重启防火墙 :systemctl restart firewalld.service
关闭防火墙 :systemctl stop firewalld.service
4,如果是阿里云服务器,可能需要去设置云服务器的安全组,克隆一个安全组规则
5,测试,如果你的windows安装了mysql可以去测试,新建一个连接或者用MyEclipse或Eclipse新建一个数据源试试.
6,如果有更好的意见或建议,欢迎大家评论。