The following articles mainly show you how to correctly install MySQL in the Linux operating system and compare the installation methods of different MySQL, the three methods include rpm installation, binary installation, and source code installation.
Comparison of installation methods
1. Use rpm for Installation
Easy to install and suitable for beginners
1. You need to download the client and server separately.
2. The installation path is not flexible, and the default path cannot be modified. One server can only install one MySQL
File Layout
/Usr/bin client programs and scripts
/Usr/sbinMySQLd Server
/Var/lib/MySQL Log File, database
/Usr/share/doc/packages document
/Usr/include/MySQL include (header) File
/Usr/lib/MySQL Library
/Usr/share/MySQL error message and Character Set File
/Usr/share/SQL-benchmark program
In most cases, it is enough to download MySQL-server and MySQL-client. The installation method is as follows:
Shell> rpm-ivh MySQL-server-VERSION.i386.rpm
Shell> rpm-ivh MySQL-client-VERSION.i386.rpm
Ii. Binary Installation
1. Easy installation
2. It can be installed in any path with good flexibility.
3. One server can install multiple MySQL instances in MySQL
1) It has been compiled, and the performance is not as good as that of source code compilation.
2) Compilation parameters cannot be customized flexibly.
Bin client program and MySQLd Server
Data Log Files, databases
Docs documentation, ChangeLog
Include (header) File
Lib Library
ScriptsMySQL_install_dbshare/MySQL error message file
SQL-benchmark program
Install
Log on as the root user and perform the following steps:
Code
- shell> groupadd MySQL
- shell> useradd -g MySQL MySQL
- shell> cd /home/MySQL
- shell>tar -xzvf /home/MySQL/MySQL-VERSION-OS.tar.gz
- shell> ln -s MySQL-VERSION-OS.tar.gz MySQL
- shell> cd MySQL
- shell> scripts/MySQL_install_db --user=MySQL
- shell> chown -R root:MySQL .
- shell> chown -R MySQL:MySQL data
- shell> bin/MySQLd_safe --user=MySQL &
Iii. Source Code Installation
1. You can customize the compilation based on your needs in the actual installed operating system, which is the most flexible.
2. Best Performance
3. One server can install multiple MySQL instances
1. Complicated Installation Process
2. Long Compilation Time
Bin client programs and scripts
Include/MySQL include (header) File
Info Info format document
Lib/MySQL Library
Libexec MySQLd Server
Share/MySQL error message file
SQL-benchmark program and crash-me test
Var database and log files
1) Remove unnecessary modules:
The installation of source code MySQL is more flexible because it can be flexibly customized for database compilation. Some compilation options can greatly enhance the performance of our database.
Run the following command to view all the compilation configuration options:
Shell>./configure -- help
If you only install the client, run the following command:
- shell> ./configure --without-server
If you do not want the log files and databases in the "/usr/local/var" directory, use one of the following configure commands:
- shell>./configure--prefix=/usr/local/MySQL
- shell>./configure--prefix=/usr/locallocalstatedir=/usr/local/MySQL/data
The first command changes the installation prefix so that all MySQL content can be installed under "/usr/local/MySQL" instead of the default "/usr/local ". The second command retains the default installation prefix, but overwrites the default directory of the database directory (usually "/usr/local/var") and changes it to/usr/local/MySQL/data. After compiling MySQL, you can use the options file to change the default socket location:
- shell> ./configure\-- with-unix-socket-path=/usr/local/MySQL/tmp/MySQL.sock
2) select only the character set to use:
Change the default Character Set and sorting rules after installation:
- shell> ./configure -- with-charset=CHARSET
- ./configure --with-collation=COLLATION
Select the character set to be installed in MySQL:
- shell>./configure --with-extra-charsets=LIST
List can be any of the following items:
Names of character sets separated by Spaces
Complex-to include all character sets that cannot be dynamically loaded all-to include all character sets in binary
3) Compile with pgcc:
Pgcc 2.90.29 or later:
CFLAGS = "-O3-mpentiumpro-mstack-align-double" CXX = gcc \ CXXFLAGS = "-O3-mpentiumpro-mstack-align-double \-felide-constructors-fno-Restrictions tions -fno-rtti"
4) use static compilation to improve performance:
- shell>./configure --with-client-ldflags=-all-static\
- --with-MySQLd-ldflags=-all-static
The above content is an introduction to the installation of MySQL in Linux. I hope you will have some gains.