码迷,mamicode.com
首页 > 数据库 > 详细

【Problem】xampp in ubuntu下命令行启动mysql报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock' (2)

时间:2019-10-10 10:26:12      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:inux   director   ati   share   sbin   ant   put   directory   register   

xampp in ubuntu下命令行启动mysql报错:

reddevil@reddevil-Lenovo:/opt/lampp$ ./bin/mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Cant connect to local MySQL server through socket /opt/lampp/var/mysql/mysql.sock (2)

启动mysql服务:

reddevil@reddevil-Lenovo:/opt/lampp$ /opt/lampp/lampp start
You need to start XAMPP as root!
reddevil@reddevil-Lenovo:/opt/lampp$ su root
Password: 
root@reddevil-Lenovo:/opt/lampp# /opt/lampp/lampp start
Starting XAMPP for Linux 1.7.7...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.

运行mysqlStart.sh:

#!/bin/bash
sudo rm -rf /var/run/mysqld
sudo mkdir /var/run/mysqld
sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysql.sock

关于此这篇文章给出很好的分析:http://www.samundra.com.np/solved-error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-varrunmysqldmysqld-sock-2/563

命令行启动mysql

reddevil@reddevil-Lenovo:/opt/lampp$ ls
bin      error  htdocs  lampp  libexec   logs     phpmyadmin    sbin   tmp
cgi-bin  etc    icons   lib    licenses  modules  RELEASENOTES  share  var
reddevil@reddevil-Lenovo:/opt/lampp$ /bin/mysql -u root -p
bash: /bin/mysql: No such file or directory
reddevil@reddevil-Lenovo:/opt/lampp$ ./bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql> 

至此,问题解决

【Problem】xampp in ubuntu下命令行启动mysql报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock' (2)

标签:inux   director   ati   share   sbin   ant   put   directory   register   

原文地址:https://www.cnblogs.com/SofuBlue/p/11646019.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!