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