Linux 安装Xampp以后,Apache服务器无法启动,以及启动后,连接sql数据库遇到的问题的解决方法
2024-10-19 06:22:50
xampp安装以后,搭建服务器的时候,我们会遇到哪些问题呢?
1、MySQL Database 可以启动,而Apache Web Server无法启动?
应该是80端口被占用,那么如何解决呢?我们可以通过查找80被哪个占用,并关闭这个进程,方法如下:
root@bt:/# netstat -lntp | grep :
tcp 0.0.0.0: 0.0.0.0:* LISTEN /apache2
关闭该服务,
root@bt:/# sudo service apache2 stop
* Stopping web server apache2 .. waiting .. [ OK ]
成功关闭。接下来,就可以启动Apache Web Server ,端口为 80.
2、在成功开启Apache Web Server 服务以后,就想调试 mysql ,发现 MySQL Database 虽然启动,但是无法打开连接sql,并出现以下错误
root@bt:/opt/lampp/var/mysql# mysql -u root -p
Enter password:
ERROR (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
这时候,我就在想如何找到 mysqld.sock 到底在什么位置? 最终没能找到,只能找到 mysql.sock 位于
root@bt:/opt/lampp/var/mysql# ls
aria_log. bt.pid ibdata1 multi-master.info performance_schema tc.log
aria_log_control challenges ib_logfile0 mysql phpmyadmin test
bt.err dvwa ib_logfile1 mysql.sock security
好的,当我们找到 mysql.sock以后,我们右键点击创建链接,并且重命名为 mysqld.sock 然后右键剪切该文件,
并把它放到显示错误提示的路径中 ,即到/var/run/下,如果没有mysqld文件夹,就得新建一个,并把mysqld.sock放进去。
那么现在就有了mysqld.sock文件,并且在/var/run/mysqld/mysqld.sock 这里。
现在,我们就可以运行
root@bt:/# mysql -u root -p
Enter password:
ERROR (): Access denied for user 'root'@'localhost' (using password: YES)
发现还是出错,这是因为之前,找不到mysqld.sock,以为是密码不对,就修改了 /opt/lampp/etc/下的my.cnf,把password改回
为默认的your_name,实际上,就是空密码。内容如下
# The following options will be passed to all MySQL clients [client]
#password =your_name
port = 3306
socket = /opt/lampp/var/mysql/mysql.sock
好的,再次运行
root@bt:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.5.-10.1.-MariaDB Source distribution
...
mysql>
成功完成,mysql的连接。
最新文章
- Nubia Z9 mini使用体验
- 实现倒计时功能js
- Cocos2d-x 核心概念 - 游戏循环与调度
- MySQL的索引类型和左前缀索引
- Google 面试题:Java实现用最大堆和最小堆查找中位数 Find median with min heap and max heap in Java
- iOS开发网络篇—网络编程基础(一)
- JSP-07-使用JavaBean封装数据
- ajax的一部分知识
- 利用switch语句计算特定的年份的月份共有几天。
- Python之路【第十七篇】:Django【进阶篇】
- 加入gitignore文件没有起作用怎么办
- python image show()方法的预览问题
- [LeetCode]题解(python):063-Unique Paths II
- 使用ObjectInputStream和ObjectOutputStream注意问题
- 循环神经网络(RNN)模型与前向反向传播算法
- [LeetCode] Array Nesting 数组嵌套
- 用简单的C语言实现多任务轮流切换(模拟操作系统线程机制)
- Shell脚本备份数据库(多库)
- 序列化与反序列化之JSON
- 『Python』内存分析_list和array
热门文章
- MySQL调优三步曲(慢查询、explain profile)
- react 组件的生命周期
- 基于requirejs+bluebird,50行代码实现轻巧实用的前端CMD加载器
- 在node中使用 ES6
- 3408: [Usaco2009 Oct]Heat Wave 热浪
- 3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题
- 解决Gerrit的git unpack error问题和error Missing unknown ec867cebfd2be97c3603c45fac03c75dcf68d0ca
- 求助,如何干掉这个不要脸的“流氓”
- 在Ubuntu Linux下制作Windows 启动安装 USB盘
- C++ 容器对象vector和list 的使用