When I connected to mysql using clsql,the following error occurred
While trying to connect to database localhost:3306/root/
using database-type MYSQL:
Error 2002 / Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)
has occurred.
[Condition of type SQL-CONNECTION-ERROR]
My mysql.sock path is "/home/myhome/var/run/mysql/mysql.sock",how
can I change the default sock path in clsql?
Here is my code, (SBCL 1.0.50 ,mysql 5.0,clsql-20130128-git)
(asdf:operate 'asdf:load-op 'clsql)
(in-package #:clsql-user)
(clsql:connect '("localhost" "username" "password" "dbname" 3306 ) :database-type :mysql)"
I would suggest creating a ~/.my.cnf or (if you have root access) /etc/my.cnf file and including a client setting for the socket, libmysqlclient might pick this up.
Failing that (or if you don't want to make a global change) the doc suggests you can specify a list of MySQL options as a separate assoc list http://clsql.b9.com/manual/connect.html which get passed into mysql_options()
Funny,the answer is that change the host from "localhost" to "127.0.0.1"
Related
I want to configure MySQL in SublimeText 3, I found that the configuration is from Build System / New Build System ...
My written code is as follows:
{
"cmd": ["C: /xampp/mysql/bin/mysql.exe", "-u", "dorbezo", "-P", "Dorbezo123", "-h", "192.168.1.99", " -e "," source $ file "," -t "],
"selector": "source.sql",
"quiet": true}
My credentials to access MySQL from Workbench are the following:
user: dorbezo,
pass: Dorbezo123,
host: port: 192.168.1.99:3306
Am I entering the connection correctly? It is worth mentioning that I connect via VPN and I have ** xampp ** started when I try to run a query, getting the following error:
** show databases; **
Unknown suffix 'D' used for variable 'port' (value 'Dorbezo123')
C: /xampp/mysql/bin/mysql.exe: Error while setting value 'Dorbezo123' to 'port'
I also mention that the port where ** xampp ** connects is 3307, since 3306 (which I use in Workbench) causes me conflict.
There are several problems with your .sublime-build file.
Your command path "C: /xampp/mysql/bin/mysql.exe" has a space in it but perhaps that was pasted into your post incorrectly. I would have expected something more like this on Windows: "C:\\xampp\\mysql\\bin\\mysql.exe".
You are using an uppercase -P for your password, it should be a lowercase -p.
You possibly need to add the port number with the uppercase "-P", "3306". I say 'possibly' because 3306 is the default port for MySQL so you may not need to specify it at all.
Using long form options is generally a good idea because they prevent letter case mistakes. e.g. --user, --password, --host, --port, --execute, --table.
Here is a MySQL.sublime-build file for you to try, the long options (with my details) work for me on Linux:
{
"cmd": ["C:\\xampp\\mysql\\bin\\mysql.exe", "--user=dorbezo", "--password=Dorbezo123", "--host=192.168.1.99", "--port=3306", "--execute=source $file", "--table"],
"selector": "source.sql"
}
Clearly storing a password in a .sublime-build file is a security risk. You should consider creating a MySQL user with an insecure password which has limited privileges.
There is also the SQLTools Sublime Text plugin which you could install, see here for the documentation. Instead of your connection details being stored in a .sublime-build file you would add them in a SQLToolsConnections.sublime-settings settings file. The documentation link above has detailed examples. I suspect you might find using this plugin easier than managing the build file. Using this plugin means there is less of a password security issue; if you use null in the password field (not in quotes) then the plugin will prompt for the password and then remember it for the session (I think).
I'm playing around with thisenter link description here Go CRUD api app. The READ.me advises that mysql needs to be configured in config/dbconn.go. In the source code, mysql is configured to use port 3306. I cloned the source code and changed the config to use port 8889, which MAMP mysql requires me to use for my own scripts (the only mysql I have on my system is through MAMP).
dbUserName := "root"
dbPass := "root"
dbIp := "127.0.0.1"
dbPortNo := 8889
When I ran cloned version of the app and tried to visit one of the routes, I got this error message
Create tables failed dial tcp 127.0.0.1:3306: connection refused
exit status 1
So I'm assuming that it's trying to connect on the port through 3306, and when I look in the util.go file of the project, I see that it's importing the config from the remote repo, rather (I'm assuming) than using the config file in the local repo that I changed to use the mysql settings for MAMP
util.go
import (
"github.com/mantishK/gonotevanilla/config"
)
My question is, if the problem is as I think it is, how do I tell util.go to use the database config file at /config/dbconn.go rather than the file that's in the remote repo.
I tried to using
"config"
and
"/config"
and I got the same error
I'm a little green at this, and I hope the issue I'm having is a simple one...edit: new information at bottom
I need to make a connection to a remote mysql (Amazon RDS) database.
After following a few tutorials, I have unixodbc and libmyodbc installed and configured on the client, but when I try to connect via isql, I get the error
[08S01][unixODBC][MySQL][ODBC 5.1 Driver]Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[ISQL]ERROR: Could not SQLConnect
The most confusing part about this error is that I'm not trying to connect to a local database, but rather to a remote one. I do not have a mysql.sock file on the client...this isn't the issue though is it?
I'm sensing a configuration error but I'm just not sure what it could be.
If I run odbcinst -j then the output is:
DRIVERS............: /etc/unixODBC/odbcinst.ini
SYSTEM DATA SOURCES: /etc/unixODBC/odbc.ini
USER DATA SOURCES..: /root/.odbc.ini
The content of /etc/unixODBC/odbcinst.ini is:
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc5.so
Setup = /usr/lib64/unixODBC/libodbcmyS.so
UsageCount = 5
[MySQL ODBC 515 Driver]
Description = ODBC 5.515 for MySQL
DRIVER = /usr/lib64/libmyodbc5-5.1.5.so
SETUP = /usr/lib64/unixODBC/libodbcmyS.so
UsageCount = 3
Please note that I had to make up this configuration myself, I did a find for libmyodbc* and found these two .so files, thus set up a driver for each of them. A search for libodbcmyS* yields:
/usr/lib64/unixODBC/libodbcmyS.so.1
/usr/lib64/unixODBC/libodbcmyS.so
/usr/lib64/unixODBC/libodbcmyS.so.1.0.0
So, I don't know what else that configuration could be.
The content of /etc/unixODBC/odbc.ini is:
[target_db]
Driver = MySQL
Server = [servername.com]
Port = 3306
Database = [databasename]
Option = 2
User = [username]
Password = [password]
I've tried different options in "Driver", changing it from MySQL, to MySQL ODBC 515 Driver, to the path to the .so file (eg: /usr/lib64/libmyodbc5.so) and all yield the same result.
I'm running:
odbcinst -i -d -f /etc/unixODBC/odbcinst.ini
Followed by:
odbcinst -i -s -l -f /etc/unixODBC/odbc.ini
Followed by:
odbcinst -s -q
Which prints out the name of my connection, ie [target_db]
Then, I try the connect:
isql -v target_db user password
or just
isql -v target_db
and get the error shown above.
Anyone happen to know what I'm doing wrong here? Thanks a bunch-
EDIT:
Wanted to mention that I'm able to connect to the database from this server using the mysql command line tools.
I installed a local mysql database, and I'm able to connect to this using isql. It seems to be ignoring my odbc.ini file entirely, i have to enter a name with the command, ie isql -v test-database, but it still tries to connect to localhost despite my settings.
I feel as though I've tried everything but will keep at it and will post if i find a solution.
You could try to connect using the ip of your server instead of the dns entry on the "Server" line of odbc.ini.. Have you verified the driver is installed with phpinfo()?
Try to set the environment variable ODBCINI with the path of your odbc.ini file.
Keep in mind that the odbc.ini file you point to must be "write-accessible" by the user that is running the program (i.e. the user must have permissions to write in this file).
chmod g+w .odbc.ini did it for me since we run the DB with ORACLE-Start and the crs-User seems to be in charge
I am running some rails app on osx, but when I launch a rails generate command type, I get this message :
/$root/vendor/bundle/ruby/2.0.0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error)
For info, my mamp server is running, and the connection must pass through /Applications/MAMP/Library/bin/mysql, so I aliased it by setting in my bash profile :
alias mysql="/Applications/MAMP/Library/bin/mysql"
Btw, what is weird, is that my rails s command works perfectly, so my app can connect to the apache server in that case
So the trick was to simply /tmp/mysql.sock to /Applications/MAMP/tmp/mysql/mysql.sock
ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
The error indicates that "mysql is not started/running". From what you describe, looks like the new location pointed to the alias has no mysql or its mysql is not started.
Look my.cnf file with the correct parameters in the new location:
/Applications/MAMP/Library/bin/mysql
Another trick is to list your running processes and look for mysql.
Also, are you sure, "rails c" is not using the sqlite3 vs mysql?
Updated:
*Courtesy of #bfavaretto
MySQL my.cnf location on OS X?
By default, the OS X installation does not use a my.cnf, and MySQL just uses the default values. To set up your own my.cnf, you could just create a file straight in /etc.
OS X provides example configuration files at /usr/local/mysql/support-files/
Update:
Take a look at this:
https://stackoverflow.com/questions/4788381/getting-cant-connect-through-socket-tmp-mysql-when-installing-mysql-on-m
My socket file is located here:
/var/run/mysqld/mysqld.sock
When I do:
rake thinking_sphinx:start
I get:
rake aborted!
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I want to tell thinking_sphinx where my socket file is. How is this possible? This issue appeared after performing a hard reboot of my slice on Slicehost.
EDITED to be (hopefully) clearer:
you can specify the mysql socket to be used in sphinx search's configuration file, sphinx.conf, via sql_sock:
sql_sock = /var/run/mysqld/mysqld.sock
(note that it depends on the sql_host setting whether this value will actually be used)
you can also use thinking_sphinx' configuration file, RAILS_ROOT/config/sphinx.yml, to set (overwrite) these values:
sql_sock: /var/run/mysqld/mysqld.sock
In the version 1.3.20 the socket path can be defined via database.yml, e.g
# database.yml
development:
adapter: mysql
database: app_name_development
username: root
password:
socket: /tmp/mysql.sock
Now, thinking-sphinx will use the socket path => /tmp/mysql.sock.
Some interesting code snippet from the edge sphinx, which states that sphinx requires TCP connections.
From thinking_sphinx/configuration.rb:
def connection
# If you use localhost, MySQL insists on a socket connection, but Sphinx
# requires a TCP connection. Using 127.0.0.1 fixes that.
address = searchd.address || '127.0.0.1'
address = '127.0.0.1' if address == 'localhost'
Mysql2::Client.new(
:host => address,
:port => searchd.mysql41,
:flags => Mysql2::Client::MULTI_STATEMENTS
)
end
The answer from ax does not work.
You can see from commit 49f467b25075666104a46b190139dd1bdbb1452f that someone's added support in SphinxHelper to set the socket. I haven't used this method, and don't have too much time to test it for you, so you're on your own with this method.
Also, curiously, in commit http://github.com/freelancing-god/thinking-sphinx/commit/a12dbd55ed9046faf6369a3d0aa452b75a31b5b6 it looks like they added support for sockets via your database.yml, however if you look at the current edge code, this seems to have been removed?
Short answer: symlink your actual mysqld.sock to the location sphinx is looking for it.