In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the methods of installing MySQL in Linux, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
1. Running platform: CentOS 6.3x86x64, which is basically equivalent to RHEL 6.3s
two。 Installation method:
There are two main ways to install MySQL: one is to compile and install by yourself through the source code, which is suitable for advanced users to customize MySQL, which is not explained here; the other is to install through compiled binaries. There are two ways to install binaries: one is a general installation method that is not specific to a specific platform, and the binaries are compressed files with the suffix .tar.gz; the second is to install them using RPM or other packages, which automatically completes the relevant configuration of the system, so it is more convenient.
3. Download the installation package:
a. Official download address:
Http://dev.mysql.com/downloads/mysql/#downloads
Or download the image file:
Http://dev.mysql.com/downloads/mirrors.html
two。 Download the file (select the appropriate release version according to the operating system):
a. General installation method
Mysql-5.5.29-linux2.6-x86_64.tar.gz
B. RPM installation method:
MySQL-server-5.5.29-2.el6.x86_64.rpmMySQL-client-5.5.29-2.el6.x86_64.rpm
4. General installation steps
a. Check whether it is installed. The-I option of grep indicates that case is ignored when matching.
[root@localhost JavaEE] # rpm-qa | grep-I mysqlmysql-libs-5.1.61-4.el6.x86room64* it can be seen that the library file has been installed, so you should uninstall it first, otherwise an overwrite error will occur. Note unloading: the-- nodeps option was used when loading, ignoring dependencies: [root@localhost JavaEE] # rpm-e mysql-libs-5.1.61-4.el6.x86_64-- nodeps
b. Add mysql groups and mysql users to set the mysql installation directory file owner and group.
The [root@localhost JavaEE] # groupadd mysql [root@localhost JavaEE] # useradd-r-g mysql mysql*useradd-r parameter indicates that the mysql user is a system user and cannot be used to log in to the system.
c. Extract the binaries to the specified installation directory, which we specify here as / usr/local
[root@localhost ~] # cd/usr/local/ [root@localhost local] # tar zxvf / path/to/mysql-5.5.29-linux2.6-x86_64.tar.gz* is pressurized and the decompressed folder mysql-5.5.29-linux2.6-x86_64 is generated in / usr/local/. The name is too long. We set up a symbolic link mysql for it to facilitate input. [root@localhost local] # ln-s mysql-5.5.29-linux2.6-x86_64 mysql
Directory structure under d. / usr/local/mysql/
Directory
Contents of Directory
Bin
Client programs and the mysqld server
Data
Log files, databases
Docs
Manual in Info format
Man
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, the directory where mysql is located, and change the group and user to which you belong.
[root@localhost local] # cd mysql [root@localhost mysql] # chown-R mysql. [root@localhost 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 runtime accesses the data directory, so the script must be executed by the user who started the mysqld process (that is, the mysql user we set up earlier) or with root, but with the parameter-- user=mysql.
[root@localhost mysql] scripts/mysql_install_db-- user=mysql* if the installation directory (unzipped directory) of mysql is not / usr/local/mysql, you must also specify directory parameters, such as [root@localhost mysql] scripts/mysql_install_db-- user=mysql\-- basedir=/opt/mysql/mysql\-- datadir=/opt/mysql/mysql/data* to return all files in the mysql/ directory except the data/ directory to those owned by root users. The mysql user only needs to be the owner of all files in the mysql/data/ directory. [root@localhost mysql] chown-R root. [root@localhost mysql] chown-R mysql data
g. Copy Profil
[root@localhost mysql] cp support-files/my-medium.cnf / etc/my.cnf
h. Add the mysqld service to the boot self-startup item.
* first you need to copy the scripts/mysql.server service script to / etc/init.d/, and rename it to mysqld. [root@localhostmysql] cp support-files/mysql.server / etc/init.d/mysqld* adds the mysqld service to the self-starting service item through the chkconfig command. [root@localhost mysql] # chkconfig-- add mysqld* Note Service name mysqld is the name we renamed when we copied mysql.server to / etc/init.d/. * check whether [root@localhost mysql] # chkconfig-- list mysqldmysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:offi. Restart the system and mysqld will start automatically. * check whether to start [root@localhost mysql] # netstat-anp | grep mysqldtcp 00 0.0.0.0anp 3306 0.0.0.0 LISTEN 2365/mysqld unix 2 [ACC] STREAM LISTENING 14396 2365/mysqld / tmp/mysql.sock* if you don't want to restart it, you can start it manually. [root@localhost mysql] # service mysqld startStarting MySQL.. SUCCESS!j. Run the client program mysql, and in the mysql/bin directory, test whether you can connect to mysqld. [root@localhost mysql] # / usr/local/mysql/bin/mysqlWelcome to the MySQLmonitor. Commands end with; or\ g.Your MySQL connection idis 2Server version:5.5.29-log MySQL Community Server (GPL) Copyright (c) 2000, 2012 Magi Oracle and/or its affiliates. All rights reserved.Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.Type 'help;' or'\ h' forhelp. The mysql > command prompt appears at Type'\ c'to clear the current input statement.mysql > quitBye*. You can enter the sql statement and type quit or exit to exit. In order to avoid entering the full path / usr/local/mysql/bin/mysql of mysql every time, add it to the environment variable and add two lines of command at the end of / etc/profile: MYSQL_HOME=/usr/local/mysqlexport PATH=$PATH:$MYSQL_HOME/bin so that you can directly enter the mysql command in shell to start the client program [root@localhost mysql] # mysqlWelcome to the MySQLmonitor. Commands end with; or\ g.Your MySQL connection idis 3Server version:5.5.29-log MySQL Community Server (GPL) Copyright (c) 2000, 2012 Magi Oracle and/or its affiliates. All rights reserved.Oracle is a registeredtrademark of Oracle Corporation and/or itsaffiliates. Other namesmay be trademarks of their respectiveowners.Type 'help;' or'\ h' forhelp. Type'\ c'to clear the current input statement.mysql >
5. RPM installation steps
a. Check whether it is installed. The-I option of grep indicates that case is ignored when matching.
[root@localhost JavaEE] # rpm-qa | grep-I mysqlmysql-libs-5.1.61-4.el6.x86_64 can be seen that the library file has been installed, so you should uninstall it first, otherwise an overwrite error will occur. Notice that the-- nodeps option is used when uninstalling, ignoring the dependencies: [root@localhost JavaEE] # rpm-e mysql-libs-5.1.61-4.el6.x86_64-- nodeps
b. To install the server-side software for MySQL, please switch to the root user:
[root@localhost JavaEE] after the installation of # rpm-ivh MySQL-server-5.5.29-2.el6.x86_64.rpm is complete, the installation process adds a mysql group and a user mysql that belongs to the mysql group to the Linux. You can view it through the id command: [root@localhost JavaEE] # id mysqluid=496 (mysql) gid=493 (mysql) groups=493 (mysql) MySQL server after installation, although the relevant files are configured, the mysqld service is not automatically started. You need to start it yourself: [root@localhost JavaEE] # service mysql startStarting MySQL.. SUCCESS! You can check whether the MySQL starts properly by checking whether the port is open: [root@localhost JavaEE] # netstat-anp | grep 3306tcp 0 0 0.0 0. 0 netstat 3306 0. 0. 0. 0. 0.
c. Install the client software for MySQL:
[root@localhost JavaEE] # rpm-ivh MySQL-client-5.5.29-2.el6.x86_64.rpm should be able to run the mysql command if the installation is successful. Note that it must be a mysqld service and open: [root@localhost JavaEE] # mysqlWelcome to the MySQLmonitor. Commands end with; or\ g.Your MySQL connection idis 1Server version: 5.5.29MySQL Community Server (GPL) Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademarkof Oracle Corporation and/or its affiliates. Other names may be trademarks oftheir respective owners.Type 'help;' or'\ h' forhelp. Type'\ c'to clear the current input statement.mysql >
D. RPM installation file distribution
Directory
Contents of Directory
/ usr/bin
Client programs and scripts
/ usr/sbin
The mysqld server
/ var/lib/mysql
Log files, databases
/ usr/share/info
Manual in Info format
/ usr/share/man
Unix manual pages
/ usr/include/mysql
Include (header) files
/ usr/lib/mysql
Libraries
/ usr/share/mysql
Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/ usr/share/sql-bench
Benchmarks
After reading the above, do you have any further understanding of Linux's method of installing MySQL? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.