服务器远程链接mysql问题解决

1、 centos下解决远程链接不上的问题。
一、查看centos 下防火墙是否关闭:
经过进程: ps -aux |grep firewalld
ps -ef |grep firewalld
经过服务:pgrep firewalld
systemctl status firewalld
关闭防火墙: systemctl stop firewalld
service iptables off
二、远程链接走的是sshd 服务,是ssh协议,端口号是 22.
查看 sshd 服务是否已开启:
经过进程: ps -aux |grep sshd
经过服务:pgrep sshd
开启服务: systemctl start sshd
把sshd 服务加入到开机启动:chkconfig sshd onphp

三、查看IP地址。
ifconfig
在windows下,cmd窗口里面,ping一下上面的ip地址,看是否能够ping通。

2、数据库操做:mysql

一、开启mysql。
systemctl start mariadb
二、首先是设置密码,会提示先输入密码
mysql_secure_installation
三、建立普通用户:
create user root@localhost identified by '123456';
mysql -u root -p
update user set host='%' where host='127.0.0.1';
flush privileges;
四、受权root用户远程登陆:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;

3、mysql远程链接不上的解决方法:
一、防火墙:
设置防火墙,开机不启动:
chkconfig firewalld off
关闭防火墙:
systemctl disable firewalld
systemctl stop firewalld
或者杀死 防火墙的进程。
查看防火墙的进程存在么:pgrep firewalld,
而后 杀死进程: kill pid
或者 pkill firewalld
二、没有远程权限
授予远程登陆权限
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;linux

三、开启sshd服务: systemctl start sshd
把sshd 服务加入到开机启动:chkconfig sshd on
web

4、在windows 访问Linux下的项目
开启Linux中 Apache服务,即httpd服务
systemctl start httpd
或者: service httpd start
Windows下面浏览器访问Linux下的项目:
浏览器地址栏输入IP地址便可:
(可经过ifconfig 查看本身的IP地址)
例如 192.168.0.1

5、Windows下配置虚拟域名方法:
配置本地hosts 文件。
位置:C:\Windows\System32\drivers\etc\hosts
添加 对应虚拟主机名便可。
192.168.226.129 linux.ccsql


mysql的CRUD;
添加:
INSERT INTO `user` (`id`, `username`, `passwd`, `sex`) VALUES ('1', 'zhangsan', '12345', '')
更新:
UPDATE `user` SET `sex`='女' WHERE (`id`='2')
删除:
DELETE FROM `user` WHERE (`id`='2')
查询:
SELECT * FROM `user`;数据库

1、 centos下解决远程链接不上的问题。
一、查看centos 下防火墙是否关闭:
经过进程: ps -aux |grep firewalld
ps -ef |grep firewalld
经过服务:pgrep firewalld
systemctl status firewalld
关闭防火墙: systemctl stop firewalld
service iptables off
二、远程链接走的是sshd 服务,是ssh协议,端口号是 22.
查看 sshd 服务是否已开启:
经过进程: ps -aux |grep sshd
经过服务:pgrep sshd
开启服务: systemctl start sshd
把sshd 服务加入到开机启动:chkconfig sshd onwindows

三、查看IP地址。
  ifconfig
  在windows下,cmd窗口里面,ping一下上面的ip地址,看是否能够ping通。centos


报错 怎么办?浏览器

数据库链接不上?出现下面的问题?
  Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ???
  怎么办?
  先查看 /etc/rc.d/init.d/mysqld status 看看mysql是否已经启动.
  若是是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql安全

  [root@localhost ~]# /etc/init.d/mysqld start
  启动 MySQL: [ 肯定 ]
  [root@localhost ~]# mysql -uroot -p

  10038?(远程没有受权)
  10060?(加入安全组)


2、数据库操做:
一、开启mysql。
  systemctl start mariadb
  二、首先是设置密码,会提示先输入密码
  mysql_secure_installation
三、建立普通用户:
  create user zhangsan@localhost identified by 'root';
  mysql -u root -p
  update user set host='%' where host='127.0.0.1';
  flush privileges;
  四、受权root用户远程登陆:
  grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
  flush privileges;
  update user set user='root' where host='localhost';
3、mysql远程链接不上的解决方法:
一、防火墙:
  设置防火墙,开机不启动:
  chkconfig firewalld off
关闭防火墙:
  systemctl disable firewalld
  systemctl stop firewalld
  或者杀死 防火墙的进程。
  查看防火墙的进程存在么:pgrep firewalld,
  而后 杀死进程: kill pid
  或者 pkill firewalld
二、没有远程权限
  授予远程登陆权限
  grant all privileges on *.* to 'root'@'%' identified by '123456';
  flush privileges;

  三、开启sshd服务: systemctl start sshd
  把sshd 服务加入到开机启动:chkconfig sshd on

4、在windows 访问Linux下的项目
  开启Linux中 Apache服务,即httpd服务systemctl start httpd或者: service httpd start
  Windows下面浏览器访问Linux下的项目:浏览器地址栏输入IP地址便可:(可经过ifconfig 查看本身的IP地址)例如 192.168.0.1

5、Windows下配置虚拟域名方法:
  配置本地hosts 文件。
  位置:C:\Windows\System32\drivers\etc\hosts
  添加 对应虚拟主机名便可。
  192.168.226.129 linux.cc


mysql的CRUD;
添加:
  INSERT INTO `user` (`id`, `username`, `passwd`, `sex`) VALUES ('1', 'zhangsan', '12345', '')
更新:
  UPDATE `user` SET `sex`='女' WHERE (`id`='2')
删除:
  DELETE FROM `user` WHERE (`id`='2')
查询:
  SELECT * FROM `user`;

6、虚拟主机
  <VirtualHost *:80>
  ServerAdmin webmaster@dummy-host.example.com
  DocumentRoot /www/docs/dummy-host.example.com
  ServerName dummy-host.example.com
  ErrorLog logs/dummy-host.example.com-error_log
  CustomLog logs/dummy-host.example.com-access_log common
  </VirtualHost>

7、设置开机启动:默认图形化界面切换为 命令行模式
   修改成命令模式multi-user.target:
  [root@localhost ~]# systemctl set-default multi-user.target
  rm '/etc/systemd/system/default.target'
  ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'
  [root@localhost ~]# systemctl get-default
  获得:multi-user.target:达到效果。
  在切换为:图形化模式:systemctl set-default graphical.target

8、配置文件说明
  A: httpd.conf Apache的主配置文件。
  B: php.ini PHP的主配置文件
  D: httpd-vhost.conf 配置虚拟主机的时候,更改的文件
  E:my.cnf linux下mysql的主配置文件

注意: Windows下面mysql的主配置文件 my.ini

相关文章
相关标签/搜索