Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I just created a new MySQL data directory using mysql_install_db:

$mysql_install_db --datadir=/home/user1/opt/mysqld/data/
Installing MySQL system tables...
091123 10:51:54 [Warning] One can only use the --user switch if running as root

Filling help tables...
091123 10:51:54 [Warning] One can only use the --user switch if running as root


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

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 machine1 password 'new-password'
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 mysql-test ; perl mysql-test-run.pl

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

The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at http://shop.mysql.com

I ran mysqld_safe to start the instance, but mysql will not connect. I can run mysqld with --skip-grant, but it won't let me set new privileges. How do I kickstart the permissions on a new MySQL instance?

$ps aux|grep mysql

root      2602  0.0  0.0  87076  1308 ?        S    Nov22   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid
mysql     2662  0.0  0.2 190676 23732 ?        Sl   Nov22   0:22 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
user1    18954  0.0  0.0  84984  1224 pts/4    S+   11:36   0:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=my.cnf
user1    18980  0.0  0.2 190160 22860 pts/4    Sl+  11:36   0:00 /usr/libexec/mysqld --defaults-file=my.cnf --basedir=/usr --datadir=/home/user1/opt/mysqld/data --pid-file=/home/user1/opt/mysqld/mysqld.pid --skip-external-locking --port=3307 --socket=/home/user1/opt/mysqld/mysql.sock
user1    20148  0.0  0.0  82236   756 pts/2    S+   12:15   0:00 grep mysql

netstat -lnp|grep mysql

tcp        0      0      *                   LISTEN      18980/mysqld
unix  2      [ ACC ]     STREAM     LISTENING     153644 18980/mysqld        /home/user1/opt/mysqld/mysql.sock
unix  2      [ ACC ]     STREAM     LISTENING     8193   -                   /var/lib/mysql/mysql.sock

Edit: There are two instances of MySQL. I want the one on port 3307. mysqld_safe is being run as user1 not root with this command: mysqld_safe --defaults-file=my.cnf

share|improve this question
What error do you get when you try to connect? Can you paste that here too? Are you sure mysqld is running? what does ps aux|grep mysql show? –  Tom O'Connor Nov 23 '09 at 17:43
How do you know where it's listening? netstat -lnp |grep mysql would be useful, too. –  womble Nov 23 '09 at 18:09

2 Answers 2

up vote 0 down vote accepted

Ah, it must use a socket file instead of a port.

mysql --socket=/home/user1/opt/mysqld/mysql.sock -uroot did the trick.

share|improve this answer

mysql -P 3307 -u root should do the trick, too.

share|improve this answer
I thought that too at first. It actually didn't work. –  User1 Nov 25 '09 at 19:30
Then there's a firewall rule or something blocking the connection. MySQL is clearly listening on port 3307. –  womble Nov 25 '09 at 20:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.