• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - error  RSS feed

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I installed MySQL on Ubuntu and now I would like to reset the root password.
I follow this instructions:
ubuntu documentation

this step works:


This also:


On this step I get the following error:


Error:


How can I solve this ?
 
Bartender
Posts: 1603
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to find where the socket has been opened -- it appears to not be at the default for your installation - /var/run/mysqld/mysqld.sock.

There are a couple ways to do that:
  • check your my.cnf file and look for a line like: socket = /home/hss/db/mysql.sock
  • run netstat --listen and locate the line for mysql -- my platform shows: unix 2 [ ACC ] STREAM LISTENING 10427 /home/hss/db/mysql.sock


  • Then, try your command again, specifying the socket location: mysql -u root -S /home/hss/db/mysql.sock

    Also, you will probably have to use the -p option so that you will be prompted for a password.
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I don't know exactly where is this file but I assume that is this?
    What should I do when there is no line like socket = /home/hss/db/mysql.sock


    my.cnf:



     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I think MySQL is not running so therefore I cannot find it inside netstat, or??
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I ran mysql
    and this is what i found with netstat --listen:

     
    Ron McLeod
    Bartender
    Posts: 1603
    232
    Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Try using ps to see the config file and socket location was  provided to mysqld (I reformatted the output):

    # ps -ef | grep mysqld

    mysql     2312  1815  0 Oct31 ?        00:05:33
        /usr/sbin/mysqld
            --defaults-file=/home/hss/current/CONF/my.cnf
            --basedir=/usr --datadir=/home/hss/db
            --plugin-dir=/usr/lib/mysql/plugin
            --user=mysql
            --log-error=/home/hss/db/mysqld.log
            --pid-file=LS-SSIeNB.pid
            --socket=/home/hss/db/mysql.sock
            --port=3306
            --wsrep_start_position=00000000-0000-0000-0000-000000000000:-1



    Edit: this step is necessary anymore since you found the socket location
     
    Ron McLeod
    Bartender
    Posts: 1603
    232
    Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    John Losty wrote:I ran mysql
    and this is what i found with netstat --listen:


    Ok - are you able to connect by specifying the socket now?
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    This is how I ran commands:





    This time


    And error:


     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The problem is I think that this line



    doesn't even starts the server. According to htop the process is not running.
     
    Ron McLeod
    Bartender
    Posts: 1603
    232
    Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Does Ubuntu use init.d scripts to start/stop platform services?  If it does, then you should probably be starting the mysql server with: sudo /etc/init.d/mysql start
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I tried this:
     
    Ron McLeod
    Bartender
    Posts: 1603
    232
    Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    As I mentioned earlier, you will probably have to use the -p option so that you will be prompted for a password:

    mysql -u root -p   or   mysql -u root -p your-password-here
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I don't have the root password, I want to change it, see my first post
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It want's password from me but I don't have it, that is why I want it to reset it.
     
    Ron McLeod
    Bartender
    Posts: 1603
    232
    Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If you are setting the password for the first time, you should be using the mysqladmin command:

    mysqladmin -u root password your-new-password
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    No I already had a password. Maybe I should just unnistal the program and install it again and set the password that way?
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I unnistaled MySQL and installed it again.
    I tried to set the root password for the first time this way, but I cant I get the following error:

     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    This is how I installed MySQL:

     
    Ron McLeod
    Bartender
    Posts: 1603
    232
    Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Maybe your uninstall did not clean up everything.  This is what I see with a fresh install on a Centos 6 distrubution:

    [root@pmgr ~]# yum -y install mysql-server

    ...

    Installed:
      mysql-server.x86_64 0:5.1.73-7.el6

    Dependency Installed:
      mysql.x86_64 0:5.1.73-7.el6                                perl-DBD-MySQL.x86_64 0:4.013-3.el6

    Dependency Updated:
      mysql-libs.x86_64 0:5.1.73-7.el6

    Complete!

    [root@pmgr ~]# service mysqld start
    Initializing MySQL database:  WARNING: The host 'pmgr' could not be looked up with resolveip.
    This probably means that your libc libraries are not 100 % compatible
    with this binary MySQL version. The MySQL daemon, mysqld, should work
    normally with the exception that host name resolving will not work.
    This means that you should use IP addresses instead of hostnames
    when specifying MySQL privileges !
    Installing MySQL system tables...
    OK
    Filling help tables...
    OK

    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:

    /usr/bin/mysqladmin -u root password 'new-password'
    /usr/bin/mysqladmin -u root -h pmgr password 'new-password'

    Alternatively you can run:
    /usr/bin/mysql_secure_installation

    which will also give you the option of removing the test
    databases and anonymous user created by default.  This is
    strongly recommended for production servers.

    See the manual for more instructions.

    You can start the MySQL daemon with:
    cd /usr ; /usr/bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl
    cd /usr/mysql-test ; perl mysql-test-run.pl

    Please report any problems with the /usr/bin/mysqlbug script!

                                                               [  OK  ]
    Starting mysqld:                                           [  OK  ]

    [root@pmgr ~]# mysqladmin -u root password secret

    [root@pmgr ~]# service mysqld restart
    Stopping mysqld:                                           [  OK  ]
    Starting mysqld:                                           [  OK  ]

    [root@pmgr ~]# mysql -u root -p
    Enter password: ++++++
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.1.73 Source distribution

    Copyright (c) 2000, 2013, 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> exit
    Bye
    [root@pmgr ~]#
     
    John Losty
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I fixed it already
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!