Link to home
Start Free TrialLog in
Avatar of huabin
huabin

asked on

Problem: Installing MySQL 5.0 on Red Hat Linux, Can't get it Running

Hi,

I totally new to Linux and MySQL, I am trying to install MySQL 5.0 on red hat enterprise linux.
First, I login as a root, and install the MySQL-Server-RPM, and MySQL-Client-RPM,
then I run "mysql" to start the server, and it doesn't work.
then I run "mysqld --user=mysql", and it still does't work.

Please thank, I have spent so many hours on this installtion, and still can't get it to work.

Jack
---------------------------------------------------------------------------------------------------------------------
[root@RHLINUX ~]# rpm -i  MySQL-server-standard-5.0.22-0.rhel4.i386.rpm
        warning: MySQL-server-standard-5.0.22-0.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
        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 RHLINUX password 'new-password'
        See the manual for more instructions.

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

       The latest information about MySQL is available on the web at http://www.mysql.com
       Support MySQL by buying support/licenses at http://shop.mysql.com
       Can't find program '/usr/bin/mysqlcheck'
       Please restart with --basedir=mysql-install-directory
       Starting MySQL...................................[FAILED]


[root@RHLINUX ~]# rpm -i  MySQL-client-standard-5.0.22-0.rhel4.i386.rpm
      warning: MySQL-client-standard-5.0.22-0.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

[root@RHLINUX ~]# mysqld

     060622  1:30:28 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld  
                  as root.
     060622  1:30:28 [ERROR] Aborting
     060622  1:30:28 [Note] mysqld: Shutdown complete


[root@RHLINUX ~]# mysqld --user=mysql
     060622  1:30:47  InnoDB: Started; log sequence number 0 43655
     060622  1:30:47 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
     060622  1:30:47 [ERROR] Do you already have another mysqld server running on port: 3306 ?
     060622  1:30:47 [ERROR] Aborting

     060622  1:30:47  InnoDB: Starting shutdown...
     060622  1:30:49  InnoDB: Shutdown completed; log sequence number 0 43655
     060622  1:30:49 [Note] mysqld: Shutdown complete
Avatar of NovaDenizen
NovaDenizen

    060622  1:30:47 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
This makes it look like mysqld has already started, so you shouldn't have to start it manually.  I'm not intimately familiar with the Red Hat RPM distribution of mysql, but I would presume that it sets up your data directory with mysql_install_db, and starts up the mysqld process as part of installation.  

Run this to see if you already have mysqld running:
ps -eadf | grep mysqld

To connect with the standard mysql client, run "mysql" (no d).  
Avatar of huabin

ASKER

Ok, I run the "ps" commad, and seems mysqld is running. But when I type "mysql", I get another error.
(Also, I using the RPM packages from mysql.org)



[root@RHLINUX ~]# ps -eadf | grep mysqld
root      3504     1  0 Jun21 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql     3519  3504  0 Jun21 ?        00:00:06 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/LINUX-VM1.pid --skip-locking
root      6450  6408  0 04:43 pts/3    00:00:00 grep mysqld



[root@RHLINUX ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@LINUX-VM1 ~]#
Is there a fifo at /var/lib/mysql/mysql.sock ?

It's not working over the socket, but we know the server's running on port 3306.  Try running "mysql --port 3306".
Avatar of huabin

ASKER

Ok, when specific the port:

[root@LINUX-VM1 mysql]# mysql --port 3306
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
---------------------------------------------------------------------------------------------------------------------------

But another big problem I found is that
mysql.sock does NOT exisit in /var/lib/mysql/

[root@RHLINUX mysql]# pwd
/var/lib/mysql
[root@RHLINUX mysql]# ls
ibdata1  ib_logfile0  ib_logfile1  LINUX-VM1.err  mysql  test

Ok, try "mysql --protocol=tcp --port=3306", that ought to force it to use the network connection.

What's in the LINUX-VM1.err error log?

Under the [mysqld] section of my.cnf, are there settings for "socket", "port", and "protocol"?

Your my.cnf is probably at /etc/mysql/my.cnf or /etc/my.cnf
Avatar of huabin

ASKER

It runs with port forcing (see below), but I still want it to run through the socket files.

--------------------------------------------------------------------------------------------------------------------
It run with "mysql --protocol=tcp --port=3306"
[root@LINUX-VM1 mysql]# mysql --protocol=tcp --port=3306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.22-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
--------------------------------------------------------------------------------------------------------------------

From the LINUX-VM1.err
--------------------------------------------------------------------------------------------------------------------
[root@LINUX-VM1 mysql]# cat LINUX-VM1.err
060623 08:20:51  mysqld started
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
060623  8:20:51  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
060623  8:20:51  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
060623  8:20:52  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
060623  8:20:52  InnoDB: Started; log sequence number 0 0
060623  8:20:52 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
060623  8:20:52 [ERROR] Do you already have another mysqld server running on port: 3306 ?
060623  8:20:52 [ERROR] Aborting

060623  8:20:52  InnoDB: Starting shutdown...
060623  8:20:54  InnoDB: Shutdown completed; log sequence number 0 43655
060623  8:20:54 [Note] /usr/sbin/mysqld: Shutdown complete

060623 08:20:54  mysqld ended
---------------------------------------------------------------------------------------------------------------------------
OK, the "my.cnf" file does not exisit on my system:

[root@LINUX-VM1 etc]# pwd
/etc
[root@LINUX-VM1 etc]# ls my*
ls: my*: No such file or directory
[root@LINUX-VM1 etc]# ls mysql*
ls: mysql*: No such file or directory
----------------------------------------------------------------------------------------------------------------------------
******************************************************************************
*****************************************************************************

[root@LINUX-VM1 mysql]# /usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

STILL HAVING THE SOCKET ERROR!
You're having the socket error because the mysql client and the mysqld server are not agreeing about whether there should be a socket file, or where that socket file is located.  That disagreement is supposed to be resolved in my.cnf.  my.cnf also lets you decide whether to run over a network port like 3306, a socket file in a certain location, or both.  How would you like clients to connect to your server, over tcp (available locally and to the network) or over the socket (available only locally)?

You definitely should have a my.cnf somewhere.  Your mysqld and mysql should be reading it to figure out where the socket file goes.  It is also possible that my.cnf is missing and mysqld and mysql are running solely off of defaults and command-line options.  Is a my.cnf location specified in the /etc/init.d/mysql startup script?  Do you have an /etc/init.d/mysql script?  Could you run "slocate my.cnf" to find all my.cnf files on your disk?

Run "mysql --help".  This should print out a great deal of help and configuration information.  Look for a line that says "Default options are read from the following files in the given order".  After that should be a list of places it looks for my.cnf.
Avatar of huabin

ASKER

I can't find the file on the system:

[root@LINUX-VM1 etc]# slocate my.cnf
[root@LINUX-VM1 etc]#

The line from "mysql --help" is as follow:

Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf /etc/my.cnf
ASKER CERTIFIED SOLUTION
Avatar of NovaDenizen
NovaDenizen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of huabin

ASKER

Ok, I copied the my-large.cnf file over, and rename it to my.cnf, and didn't make many modification to the cnf file.

"Change every instance of the 'socket' setting to fix the location of the socket file": I cannot even find this mysql.sock file, how can i change the location.

I really appreicate your help!

--------------------------------------------------------------------------------------------------------------------------------
[root@LINUX-VM1 etc]# pwd
/etc
[root@LINUX-VM1 etc]# cp /usr/share/doc/MySQL-server-standard-5.0.22/my-large.cnf .
[root@LINUX-VM1 etc]# mv my-large.cnf my.cnf

--------------------------------------------------------------------------------------------------------------------------------
[root@LINUX-VM1 etc]# cat my.cnf
# Example MySQL config file for large systems.
#
# This is for a large system with memory = 512M where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id       = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Point the following paths to different dedicated disks
#tmpdir         = /tmp/
#log-update     = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 64M
#bdb_max_lock = 100000

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 256M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 64M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
[root@LINUX-VM1 etc]#
> "Change every instance of the 'socket' setting to fix the location of the socket file": I cannot even find this mysql.sock file, how can i change the location.

I'm talking about the "socket=" settings in /etc/my.cnf . Right now they are all set to /var/lib/mysql/mysql.sock.  Is this alright with you?  You need to make sure that all your local users will have access to the directory containing the socket file, but access to /var/lib/mysql should probably be restricted since you only want the mysql user account poking around in there.  Maybe changing them to /var/run/mysql.sock would be better (if not strictly adhering to linux filesystem standards).

Set up the socket= lines the way you want them, then restart mysqld, and you ought to be set.  Make sure that the memory usage and concurrency settings in the [mysqld] section aren't too big (or small) for your machine.
Avatar of huabin

ASKER

thanks, it's running the way I wanted now.