CentOS7安装和配置mysql步骤
1.安装
- 安装mysql客户端:yum install mysql
- 安装mysql 服务器端:yum install mysql-server ,yum install mysql-devel
- yum安装mysql-server没有可用包问题解决方法:
- step 1: wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
- step 2: rpm -ivh mysql-community-release-el7-5.noarch.rpm
- yum安装mysql-server没有可用包问题解决方法:
- 启动mysql服务:service mysqld start
- 为root账号设置密码:mysqladmin -u root password ‘new-password’(默认没有密码,直接回车)
2.远程连接
-
暴力修改user表:update user set host = ‘%’ where user = ‘root’
-
命令授权:
-
grant select,insert,update,delete,create,drop on mydb.mytable to lzpddd@192.168.1.88 identified by 'mypassword'; -- 给来自192.168.1.88的用户lzpddd分配可对数据库 mydb的mytable表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为'mypassword';
-
grant all privileges on *.* to lzpddd@192.168.1.88 identified by 'mypassword'; -- 给来自192.168.1.88的用户lzpddd分配可对所有数据库的所有表进行所有操作的权限限,并设定口令为'mypassword';
-
grant all privileges on *.* to lzpddd@'%' identified by 'mypassword'; -- 给来自任何IP地址的用户lzpddd分配可对所有数据库的所有表进行所有操作的权限限,并设定口令为'mypassword';
-
-
关闭服务器端防火墙或者开放3306端口(阿里云服务器在控制台添加安全组规则)
-
ubuntu需要修改文件$sudo gedit /etc/mysql/my.cnf
skip-networking => # skip-networking
或者
bind-address=127.0.0.1 => bind-address= 你机器的IP
3.关于mysql配置文件
- 以后遇到问题再一条条补充吧。。。