1. Check if it is installed, grep's-i option indicates ignore case when matching
Rpm-qa|grep-i MySQL
* You can see that the library file has been installed, should be uninstalled first, or there will be overwrite errors. Note unloading: The--nodeps option is used when loading, ignoring dependencies
RPM-E mysql-libs-5.1.61-4.el6.x86_64--nodeps
2. Add MySQL group and MySQL user to set the MySQL installation directory file owner and owning group.
Groupadd MySQL
Useradd-r-G MySQL MySQL
The *useradd-r parameter indicates that the MySQL user is a system user and cannot be used to log on to the system.
3, extract the binary files to the specified installation directory, we specify here as/usr/local
cd/usr/local/
Tar zxvf/path/to/mysql-cluster-gpl-7.3.11-linux-glibc2.5-x86_64.tar.gz
* After pressurization in/usr/local/generate understand the pressure after the folder mysql-5.5.29-linux2.6-x86_64, this name is too long, we create a symbolic link for it mysql, convenient input.
Ln-s mysql-cluster-gpl-7.3.11-linux-glibc2.5-x86_64 MySQL
Directory structure under/usr/local/mysql/
Directory |
Contents of Directory |
Bin |
Client programs and the mysqld server |
Data |
Log files, databases |
Docs |
Manual in Info format |
Mans |
Unix manual Pages |
Include |
Include (header) files |
Lib |
Libraries |
Scripts |
mysql_install_db |
Share |
Miscellaneous support files, including error messages, sample configuration files, SQL for database installation |
Sql-bench |
Benchmarks |
E. Go to the MySQL folder, which is the directory where MySQL resides, and change the group and user to which it belongs.
[[email protected] local] #cd MySQL
[[email protected] MySQL] #chown-r MySQL.
[R[email protected] MySQL] #chgrp-r MySQL.
F. Execute the mysql_install_db script to initialize the data directory in MySQL and create some system tables. Note that the MySQL service process mysqld accesses the data directory, so it must be executed by the user who started the mysqld process (the MySQL user we set up earlier), or by root, but with the parameter--user=mysql.
[Email protected] mysql]scripts/mysql_install_db--user=mysql
* If the MySQL installation directory (extract directory) is not/usr/local/mysql, then you must also specify the directory parameters, such as
[Email protected] mysql]scripts/mysql_install_db--user=mysql \
--basedir=/opt/mysql/mysql \
--datadir=/opt/mysql/mysql/data
* All files in the mysql/directory except the data/directory are changed back to the root user, and the MySQL user only needs to be the owner of all files in the mysql/data/directory.
[[email protected] mysql]chown-r root.
[[email protected] mysql]chown-r MySQL data
G. Copying a configuration file
[[email protected] MySQL] CP support-files/my-medium.cnf/etc/my.cnf
H. Add the Mysqld service to the boot entry.
* First, you need to copy the Scripts/mysql.server service script to/etc/init.d/and rename it to Mysqld.
[[email protected]] CP support-files/mysql.server/etc/init.d/mysqld
* The MYSQLD service is added to the self-starting service item via the Chkconfig command.
[[email protected] MySQL] #chkconfig--add mysqld
* Note Service name Mysqld is the name that we renamed when we copied Mysql.server to/etc/init.d/.
* See if Add success
[[email protected] MySQL] #chkconfig--list mysqld
Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
I. Restart the system and the mysqld will start automatically.
* Check whether to start
[[email protected] MySQL] #netstat-anp|grep mysqld
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
UNIX 2 [ACC] STREAM LISTENING 14396 2365/mysqld/tmp/mysql.sock
* If you do not want to reboot, you can start it manually.
[[email protected] MySQL] #service mysqld start
Starting MySQL. success!
J. Run the client program MySQL, and in the Mysql/bin directory, test whether you can connect to mysqld.
[Email protected] Mysql]#/usr/local/mysql/bin/mysql
Welcome to the Mysqlmonitor. Commands End With; or \g.
Your MySQL Connection Idis 2
Server Version:5.5.29-log MySQL Community Server (GPL)
Copyright (c), 2012,oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of the Oracle Corporation and/or its affiliates. Other names Betrademarks of their respective owners.
Type ' help; ' or ' \h ' forhelp. Type ' \c ' to clear the current input statement.
Mysql> quit
Bye
* The mysql> command prompt appears, you can enter the SQL statement, enter quit or exit. To avoid entering MySQL's full path/usr/local/mysql/bin/mysql each time, add it to the environment variable, and then add two lines of command to the/etc/profile:
Mysql_home=/usr/local/mysql
Export path= $PATH: $MYSQL _home/bin
This allows you to start the client program by entering the MySQL command directly in the shell.
[[email protected] MySQL] #mysql
Welcome to the Mysqlmonitor. Commands End With; or \g.
Your MySQL Connection Idis 3
Server Version:5.5.29-log MySQL Community Server (GPL)
Copyright (c), 2012,oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of the Oracle Corporation and/or its
Affiliates. Other Namesmay is trademarks of their respective
Owners.
Type ' help; ' or ' \h ' forhelp. Type ' \c ' to clear the current input statement.
Mysql>
Linux Install MySQL Service