mysql-connect error beginner - mysql

I finished a web page in my computer and it was saved in my pen drive. Now I uploaded the files .html and .php to the server, and I exported the database of my pen drive and imported it on the web address using phpmyadmin. Seems like I'm having the following problem:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /home/t1g01/doador.php on line 40
The files in my pen drive are working fine. But not in the server. Can anyone help me please? When I explore the tables in the http://address.com/phpmyadmin/ there are normal, with data.
I read something in another topic about restarting the mysql by typing /etc/init.d/mysql restart or ln -s /var/lib/mysql/mysql.sock /tmp/ . If that's solve my problem, where am I supposed to type this ? I'm new at this server stuff.
Sorry for any mistake in English, and thanks in advance for the attention.

MySQL has a page for common errors and troubleshooting help:
http://dev.mysql.com/doc/refman/5.1/en/common-errors.html
I also contributed a wiki page about connection troubleshooting:
http://forge.mysql.com/wiki/Error2003-CantConnectToMySQLServer
You should also check whether your MySQL instance is using /tmp/mysql.sock or some other location for the mysql.sock file. It's not uncommon for PHP and MySQL to have different ideas about where that file lives.
So check php.ini and mysql.cnf on your server.

Related

XAMPP, MAMP, MySQL errors

I'm facing a lot of errors at the moment ranging from "No such file or directory" to "Error 403 - Access to the requested directory is only available from the local network." along with a series of permission obstacles relating to mysql.
Admittedly I was playing around with mysql, XAMPP and MAMP today (I'm new to back-end programming) and think I've screwed something up somewhere that's preventing them from working correctly.
Specifically, I'm using XAMPP now and while the status is fine (green) and connected to my IP address, along with MySQL, Apache and ProFTPD services all being connected, I can't find any of the related XAMPP files needed to resolve Error 403. Eg.
Bryans-MacBook-Pro:~ bryanjordan$ chmod -R 777 /Applications/XAMPP/xamppfiles/var
chmod: /Applications/XAMPP/xamppfiles/var: No such file or directory
When I open XAMPP, right-click and all in the Applications directory, all I see is a Contents folder with no reference to xamppfiles.
To clarify, I downloaded XAMPP, imported into Applications, opened, connected to servers and once re-directed in my browser, clicked phpMyAdmin but reached the 403 Error.
I've also linked MAMP and don't have this issue. I can access phpMyAdmin fine through this process.
I should also note, that even though I have MAMP operating fine, I can't access mysql via the command line even when I use the path directory instead of a simple, mysql -u root -p call. Instead I get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
I'm unsure if this is related but before downloading MAMP or XAMPP I was able to type "localhost/~bryanjordan" into the browser and I'd be redirected to my Sites directory. When I type the same URL in now, I receive this error:
The requested URL /~bryanjordan/ was not found on this server.
Thanks for the help!
Setting up xampp or mamp should be simple to setup. Here is a link to a handy tutorial: https://www.webucator.com/how-to/how-install-start-test-xampp-on-mac-osx.cfm
For XAMPP if it cannot find the folder make sure its actually in your applications folder and make sure your system has permissions to read and write to it.
For MAMP or even XAMPP, if you cannot start your mysql it might be permissions. Please see the link above for the relevant command to run on the command line.
Also given the amount of errors you are having i would recommend removing both and starting from scratch with just one of them using my link above.
Hope this helps!

mysqldump/mysql error with WP-DB Manager

Hi I am getting an error with the Wordpress WP-DBManager Plugin:
MYSQL dump path does NOT exist. Please check your mysqldump path under DB Options. If uncertain, contact your server administrator.
MYSQL path does NOT exist. Please check your mysql path under DB Options. If uncertain, contact your server administrator.
IT Server administrator doesn't know what to do.
So I have refered to this article: https://www.hacksparrow.com/wp-dbmanager-error-mysql-dump-path-does-not-exist-please-check-your-mysqldump-path-under-db-options.html
I am running AWS, ubuntu lamp stack - mysql 5.6, php7.0
I have checked /usr/bin and no mysqldump or mysql folder.
In the php.ini folder there is this line ;open_basedir =
Do I create mysqldump and mysql folders? and set open_basedir to open_basedir = /usr/bin/ I am not quite sure?
Or based on that article there was modules to add - <IfModule sapi_apache2.c>...
I could not find the httpd.conf file, where would I find this file?
Well, imagine trying to revive this fossil...welp. Either way, seems like this issue is still relevant for some people and no answer.
Most, if not all major server will use the following paths that you can put in the DB Options (assuming this problem originated in WP-DBManager)
/usr/bin/mysqldump
/usr/bin/mysql
This will give you the green light you're looking for

Mamp server wont start Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in

Mamp servers won't start it seems apache will but mysql won't. I really have no idea what I need to do to resolve this. Please help.
Something similar happened to me, I hope that what has helped me, will also help you.
I just upgraded MAMP from 4.06 to 4.1, and, mysteriously, it has suddenly stopped working access to phphMyAdmin, with this error:
#2002 - No such file or directory - The server is not responding (or the local server's socket is not correctly configured).
After much reading and testing, this has finally been the answer that has worked for me:
phpmyadmin - error 2002 - on Mac
Steps:
Locate config.inc.php file. You can find it in /Applications/MAMP/bin/phpMyAdmin
Edit it, using some text editor (Sublime 2, TextEdit, Text Wrangler,...)
Locate this text: $cfg['Servers'][$i]['host'] = 'localhost';
Replace localhost with 127.0.0.1
$cfg['Servers'][$i]['host'] = '127.0.0.1';
Save it and close.
Restart servers (or stop and start), or just start them.
Try to access to phpMyAdmin.
It has worked for me, I hope for you too.
Simply remove two files
ib_logfile0 and ib_logfile1 from /Applications/MAMP/db/mysql56
I researched and found 2 (rather 3) solutions for this particular issue wherein Apache would start but MySQl would not. They were
1. Changing localhost to 127.0.0.1
2. Renaming the ib_logfile# to ib_logfile_#
3. Killing existing mysqld process
While none of the above approaches worked; what worked instead was the following
Surprisingly when MAMP was installed, it did not create mysql_error_log.err file under /Applications/MAMP/logs folder. I created this file under the same directory and MySQL service turned green in MAMP window. I found this file missing when I was attempting to start MySQL service directly using the bash script 'startMysql.sh' inside /Applications/MAMP/bin
Can add another cause to the problem. Since all other answers did not work for me, I took a further look into mysql_error_log.err file at /Applications/MAMP/logs folder and found the following:
[ERROR] Another process with pid 1083 is using unix socket file.
[ERROR] Unable to setup unix socket lock file.
[ERROR] Aborting
So my guess is, that somehow there was an old process of mysql stuck while shutting down the server.
Restarting my mac solved the problem, but it should also work if you kill the named process (in my case pid 1083) with:
sudo kill -1083 PID

Problems with mysql config - want to understand

i know that there are many questions which are connected with my question, but nothing helps me to come to my goal.
I'm on mac osx 10.10.4
in the past i had MAMMP installed on my mac. Later i deleted it to configure my local hosts by my own. In the meantime i use vagrant for this. But i want to understand how the local mysql config works.
My problem:
If i type "mysql -uroot" i get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
The /Applications/MAMMP/.. folder are deleted and not there. So i think there must be a config file where this is inserted. But i cant find this file. Not in /etc/my.cnf and not in /usr/local/mysql/support-files/... nowhere...
Could anyone give me hints where my config for that is destroyed and how i can reapair it?
Would be great to hear from you guys. Thanks

setting up MySQL Workbench with MAMP - missing 'mysql.sock' file

I am having trouble connecting MySQL Workbench to MAMP. I am using version MySQL Workbench version 6.0 and MAMP version 3.0.3.
I have followed the instructions on this link: http://www.rubberneckdesigns.com/mamp/how-to-set-up-mysql-workbench-for-a-mamp-server/comment-page-1/#comment-6539 (this is just basic instructions to setting up MySQL Workbench with MAMP so no need to look through if you are familiar with the set up steps)
It all goes okay until the step were I have to select the Configuration File as:
/Applications/MAMP/tmp/mysql/mysql.sock
This file does not appear to be in this location or anywhere else on my computer.
In the answer to this link: Database connection "Mysql" is missing and mysql.sock is missing, he says he managed to figure out that his mysql.sock file was actually hidden, however I have my Mac set to display hidden files and I can see all my other hidden files, but still no sign of this file. He said after finding it was hidden he went to his database configuration file and added the following:
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock'
Does anyone know what file he is referring to when he says database configuration file? I have tried figuring it out using Google but no luck. I am new to MAMP and new to MySQL Workbench.
This problem with the mysql.sock file, seems to be a problem for a lot of people. If anyone has a better solution than adding the above command to the database configuration file or can shed some light on this problem I would love to hear it.
Thanks
I have not been able to figure out where the mysql.sock file is, Mike Lischke has left a comment saying the socket file is created dynamically when you open a connection, which could be the case, but I do not know much about MySQL and the files so I can not confirm if this is correct, however, I have found the solution to my problem.
The overall problem was that I could not connect MySQLWorkbench to my Local Server (MAMP) as I could not find the mysql.sock file. When I tried to connect I was getting an error message saying it could not find the mysql.sock file.
The solution to my problem was to instead of setting the 'Hostname' in the MySQLWorkbench set up window as 'localhost', which is suggested in the guide I followed, I instead set it to the IP '127.0.0.1'. I then set the 'Connection Method' to 'Standard (TCP/IP)' instead of 'Local Socket/Pipe'. I believe what this is doing is setting it up to connect through the IP rather than the Socket, meaning the mysql.sock file is no long necessary.
This is a very simple solution and in hindsight it makes sense and I probably should have known this from the start, however because I am new to MySQL I didn't. If anyone else is having a similar problem connecting, I hope this helps.