The path of mysqld started after mysql binary is not installed by the root user is incorrect.

Source: Internet
Author: User

1. Non-root users install the binary MySQL distribution Edition

Create user

> Useradd fc

> Passwd fc

Enter password:

...

Log On with fc and upload the binary mysql version. My mysql 32-bit mysql-5.1.57-linux-i686-glibc23.tar.gz

After decompression, create a permission table

] $ Scripts/mysql_install_db -- basedir =/home/fc/app/mysql -- datadir =/home/fc/app/mysql/data/3307 -- user = fc

(Note: The following parameters must be specified. In addition, it is best to run together in scripts/mysql_install_db. This is also the case in the official documentation to avoid errors, which may cause startup errors later)

The permission table is also initialized, and then the configuration file my. cnf is specified in the $ HOME directory:

# Example MySQL config file for medium systems. # This is for a system with little memory (32 M-64 M) where MySQL plays # an important part, or systems up to 128 M where MySQL is used together with # other programs (such as a web server) # MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You can copy this option file to one of those # locations. for information about these locations, see: # http://dev.mysql.com/doc/mysql/en/option-files.html## 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_passwordport = 3307 socket =/home/fc/app/mysql/tmp/3307/mysql. sock # Here follows entries for some specific programs # The MySQL server [mysqld] character-set-server = utf8port = 3307 socket =/home/fc/app/mysql/tmp/3307/ mysql. sockskip-external-lockingbasedir =/home/fc/app/mysqldatadir =/home/fc/app/mysql/data/3307/log-error =/home/fc/log/3307 /mysqld. errpid-file =/home/fc/app/mysql/tmp/3307/mysql. bytes = bytes = 1Mtable_open_cache = 64sort_buffer_size = bytes = 8Mmax_connections = 200slow_query_log = 1 #{0 | 1 off | on} slow_query_log_file =/home/fc/log/3307 /mysql-slow.loglong_query_time = 1 # table queries that are not updated frequently, cache query query_cache_type = 1query_cache_size = 10Mgeneral_log = 0general_log_file =/home/fc/log/3307/mysql. logquery_cache_size = 8 M # skip-networkingskip-name-resolveskip-innodb-checksums # Replication Master Server (default) # binary logging is required for replicationlog-bin =/home/fc/log/3307/mysql-bin # binary logging format-mixed recommendedbinlog_format = mixedbinlog_cache_size = bytes = 8sync_binlog = 20 # uncomment the following if you are using InnoDB tablesinnodb_data_home_dir =/home/fc/data/3307/innodb_data_file_path = ibdata1: 10 M: bytes =/home/fc/data/3307/bytes = 800Msort_buffer_size = 5Mtmp_table_size = bytes = 64 # default unit: bytes = 8innodb_log_file_size = bytes = 8Mdefault-storage-engine = bytes = 1 # Set.. _ log_file_size to 25% of buffer pool size # innodb_log_file_size = 5 M # bytes = 8 M # bytes = 1 # bytes = Second = 2 [mysqldump] quickmax_allowed_packet = 16 M [mysqld_safe] log- error =/home/fc/app/mysql/log/3307/mysqld. logpid-file =/home/fc/app/mysql/tmp/3307/mysql. pid [mysql] no-auto-rehashport = 3307 socket =/home/fc/app/mysql/tmp/3307/mysql. sock # Remove the next comment character if you are not familiar with SQL # safe-updates [myisamchk] key_buffer_size = bytes = 20Mread_buffer = 2Mwrite_buffer = 2 M [mysqlhotcopy] interactive-timeout

Okay. Everything is ready. You can start it.

2. Start the mysqld Process

Go to the basedir directory fc/app/mysql

Mysql] $ cd bin

Bin] $ mysqld_safe -- defaults-file = ~ /My. cnf &

Started successfully. view the process

Ps-ef | grep mysqld found the problem

fc    7780  7582 24 16:42 pts/10   00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=~/my.cnf --basedir=/home/fc/app/mysql --datadir=/home/fc/app/mysql/data/3307/ --log-error=/home/fc/app/mysql/log/3307/mysqld.log --pid-file=/home/fc/app/mysql/tmp/3307/mysql.pid --socket=/home/fc/app/mysql/tmp/3307/mysql.sock --port=3307

Not found. Although the mysqld program started in the fc/app/mysql/bin directory is in progress, it is mysqld in/usr/lcoal/mysql, why?

After searching for parameters for a long time, we found that there was no configuration error and we could not solve it all the time. If we changed the startup method:

Go to the base Directory FC/APP/MySQL

MySQL] $ bin/msyqld_safe -- defaults-file = ~ /My. CNF &

In this way, the mysqld process will be searched again after startup, and everything will be normal. Why?

I think the reason may be:

Mysqld_safe is the daemon of mysqld. It is also a shell script. In the script, the default basedir is: usr/local/mysql, if we enter the bin directory when starting mysqld, this directory cannot be found in this daemon. If so, the directory/usr/local/mysql/will be automatically matched, I installed mysql in this directory, so the system automatically matches this mysqld program and runs it.

Let's take a look at the shell code of mysqld_safe:

MY_PWD=`pwd`# Check for the directories we would expect from a binary release installif test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION"then  # BASEDIR is already overridden on command line.  Do not re-set.   # Use BASEDIR to discover le.  if test -x "$MY_BASEDIR_VERSION/libexec/mysqld"  then    ledir="$MY_BASEDIR_VERSION/libexec"  elif test -x "$MY_BASEDIR_VERSION/sbin/mysqld"  then    ledir="$MY_BASEDIR_VERSION/sbin"  else    ledir="$MY_BASEDIR_VERSION/bin"  fielif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/bin/mysqld"then  MY_BASEDIR_VERSION="$MY_PWD"          # Where bin, share and data are  ledir="$MY_PWD/bin"                   # Where mysqld is# Check for the directories we would expect from a source installelif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/libexec/mysqld"then  MY_BASEDIR_VERSION="$MY_PWD"          # Where libexec, share and var are  ledir="$MY_PWD/libexec"               # Where mysqld iselif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/sbin/mysqld"then  MY_BASEDIR_VERSION="$MY_PWD"          # Where sbin, share and var are  ledir="$MY_PWD/sbin"                  # Where mysqld is# Since we didn't find anything, used the compiled-in defaultselse  MY_BASEDIR_VERSION='/usr/local/mysql'  ledir='/usr/local/mysql/bin'fi

If we enter the bin directory:
Run ledir to else
My_basedir_version = '/usr/local/mysql'
Ledir = '/usr/local/MySQL/bin'
Normally: "$ my_pwd/bin/mysqld"
The problem is that MySQL starts from/usr/loca/MySQL/bin/mysqld Without CD to MySQL basedir.

PS: attached connection issues

Since we start the connection according to the socket, if we use localhost or the default status to connect to MySQL during connection, we must use the specified socket full path to connect. Otherwise, the system will search for/tmp/MySQL. socket by default. If no result is found, an error is returned;
Of course, we can also use the-H 127.0.0.1 method to connect, so we do not need to specify the-s socket path;

There are two MySQL Connection Methods: socket and TCP/IP.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.