一、 centos下解決遠(yuǎn)程連接不上的問(wèn)題。
1、查看centos 下防火墻是否關(guān)閉:
通過(guò)進(jìn)程: ps -aux |grep firewalld
ps -ef |grep firewalld
通過(guò)服務(wù):pgrep firewalld
systemctl status firewalld
關(guān)閉防火墻: systemctl stop firewalld
service iptables off
2、遠(yuǎn)程連接走的是sshd 服務(wù),是ssh協(xié)議,端口號(hào)是 22.
查看 sshd 服務(wù)是否已開(kāi)啟:
通過(guò)進(jìn)程: ps -aux |grep sshd
通過(guò)服務(wù):pgrep sshd
開(kāi)啟服務(wù): systemctl start sshd
把sshd 服務(wù)加入到開(kāi)機(jī)啟動(dòng):chkconfig sshd on
3、查看IP地址。
ifconfig
在windows下,cmd窗口里面,ping一下上面的ip地址,看是否可以ping通。
報(bào)錯(cuò) 怎么辦?
數(shù)據(jù)庫(kù)連接不上?出現(xiàn)下面的問(wèn)題?
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ???
怎么辦?
先查看 /etc/rc.d/init.d/mysqld status 看看mysql是否已經(jīng)啟動(dòng).
如果是權(quán)限問(wèn)題,則先改變權(quán)限 #chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start
啟動(dòng) MySQL: [ 確定 ]
[root@localhost ~]# mysql -uroot -p
10038?(遠(yuǎn)程沒(méi)有授權(quán))
10060?(加入安全組)
相關(guān)教程:mysql視頻教程
二、數(shù)據(jù)庫(kù)操作:
1、開(kāi)啟mysql。
systemctl start mariadb
2、首先是設(shè)置密碼,會(huì)提示先輸入密碼
mysql_secure_installation
3、創(chuàng)建普通用戶:
create user zhangsan@localhost identified by 'root';
mysql -u root -p
update user set host='%' where host='127.0.0.1';
flush privileges;
4、授權(quán)root用戶遠(yuǎn)程登錄:
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
update user set user='root' where host='localhost';
相關(guān)教程:mysql視頻教程
三、mysql遠(yuǎn)程連接不上的解決方法:
1、防火墻:
設(shè)置防火墻,開(kāi)機(jī)不啟動(dòng):
chkconfig firewalld off
關(guān)閉防火墻:
systemctl disable firewalld
systemctl stop firewalld
或者殺死 防火墻的進(jìn)程。
查看防火墻的進(jìn)程存在么:pgrep firewalld,
然后 殺死進(jìn)程: kill pid
或者 pkill firewalld
2、沒(méi)有遠(yuǎn)程權(quán)限
授予遠(yuǎn)程登錄權(quán)限
grant all privileges on *.* to 'root'@'%' identified by '123456';
flush privileges;
3、開(kāi)啟sshd服務(wù): systemctl start sshd
把sshd 服務(wù)加入到開(kāi)機(jī)啟動(dòng):chkconfig sshd on
四、在windows 訪問(wèn)Linux下的項(xiàng)目
開(kāi)啟Linux中 Apache服務(wù),即httpd服務(wù)systemctl start httpd或者: service httpd start
Windows下面瀏覽器訪問(wèn)Linux下的項(xiàng)目:瀏覽器地址欄輸入IP地址即可:(可通過(guò)ifconfig 查看自己的IP地址)例如 192.168.0.1
五、Windows下配置虛擬域名方法:
配置本地hosts 文件。
位置:C:\Windows\System32\drivers\etc\hosts
添加 對(duì)應(yīng)虛擬主機(jī)名即可。
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`;
六、虛擬主機(jī)
<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>
七、設(shè)置開(kāi)機(jī)啟動(dòng):默認(rèn)圖形化界面切換為 命令行模式
修改為命令模式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:達(dá)到效果。
在切換為:圖形化模式:systemctl set-default graphical.target
八、配置文件說(shuō)明
A: httpd.conf Apache的主配置文件。
B: php.ini PHP的主配置文件
D: httpd-vhost.conf 配置虛擬主機(jī)的時(shí)候,更改的文件
E:my.cnf linux下mysql的主配置文件
注意: Windows下面mysql的主配置文件 my.ini
相關(guān)教程:PHP視頻教程
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com