安装MySQL
1.更新操作系统
$ yum update -y
2.安装mysql数据库,在CentOS 7.2 中,使用了mariadb替代了官方的mysql
$ yum install mariadb-server -y
3.启动数据库
$ systemctl start mariadb.service
4.进行安全配置
$ mysql_secure_installation
5.录入root密码,默认为空,直接回车,设置密码,删除匿名用户,不允许root远程登录,删除测试数据库,刷新权限,完成安装。
6.测试
$ musql -uroot -p
Enter password:
MariaDB[(none)]> show databases;
....
Windows远程连接centOS的mysql
因为已经安装好了mysql
1.首先进入mysql
mysql -u root -p登录mysql
2.利用以下命令为root开放远程连接权限。
grant all privileges on *.* to 'root'@'%' identified by 'yuorpassword';
3.exit退出mysql,设置防火墙
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=3306/udp --permanent
firewall-cmd --reload
4.打开可视化连接工
具输入
ip:输入你要连接的服务器ip
用户名:root
密码:yourpassword
另外,一些常用mysql命令