Two ways to install MySQL on Linux
1. Running platform: CentOS 6.3 x86_64, basically equivalent to RHEL 6.3
2. Installation method:
There are two main ways to install MySQL: one is through source code Compile and install by yourself. This feature is suitable for advanced users to customize MySQL and will not be explained here. The other is to install through compiled binary files. There are two ways to install binary files: one is a general installation method that is not specific to a specific platform, and the binary file used is a compressed file with the suffix .tar.gz; the second is to use RPM or other packages for installation. This installation process will automatically complete 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 mirror file:
http://dev.mysql.com/downloads/mirrors.html
2. Download the file (Select the corresponding release version according to the operating system):
a. Common 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.rpm MySQL-client-5.5.29-2.el6.x86_64.rpm
4. Common installation steps
a. . .
[root@localhost JavaEE]#rpm -qa|grep -i mysql mysql-libs-5.1.61-4.el6.x86_64 *可见已经安装了库文件,应该先卸载,不然会出现覆盖错误。注意卸:载时使用了--nodeps选项,忽略了依赖关系: [root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
c. Extract the binary file to the specified installation directory, which we specify here as /usr/local
[root@localhost JavaEE]#groupadd mysql [root@localhost JavaEE]#useradd -r -g mysql mysql *useradd -r参数表示mysql用户是系统用户,不可用于登录系统。
d. The directory structure under /usr/local/mysql/
##Contents of Directory | |||||||||||||||||||||
Client programs and the mysqld | server|||||||||||||||||||||
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. 进入mysql文件夹,也就是mysql所在的目录,并更改所属的组和用户。 [root@localhost local]#cd mysql [root@localhost mysql]#chown -R mysql . [root@localhost mysql]#chgrp -R mysql . Copy after login f. 执行mysql_install_db脚本,对mysql中的data目录进行初始化并创建一些系统表格。注意mysql服务进程mysqld运行时会访问data目录,所以必须由启动mysqld进程的用户(就是我们之前设置的mysql用户)执行这个脚本,或者用root执行,但是加上参数--user=mysql。 [root@localhost mysql]scripts/mysql_install_db --user=mysql *如果mysql的安装目录(解压目录)不是/usr/local/mysql,那么还必须指定目录参数,如 [root@localhost mysql]scripts/mysql_install_db --user=mysql \ --basedir=/opt/mysql/mysql \ --datadir=/opt/mysql/mysql/data*将mysql/目录下除了data/目录的所有文件,改回root用户所有,mysql用户只需作为mysql/data/目录下所有文件的所有者。 [root@localhost mysql]chown -R root . [root@localhost mysql]chown -R mysql data Copy after login g. 复制配置文件 [root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf Copy after login h. 将mysqld服务加入开机自启动项。 *首先需要将scripts/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。 [root@localhostmysql] cp support-files/mysql.server /etc/init.d/ mysqld *通过chkconfig命令将mysqld服务加入到自启动服务项中。 [root@localhost mysql]#chkconfig --add mysqld *注意服务名称mysqld就是我们将mysql.server复制到/etc/init.d/时重命名的名称。 *查看是否添加成功 [root@localhost mysql]#chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off i. 重启系统,mysqld就会自动启动了。 *检查是否启动 [root@localhost 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 *如果不想重新启动,那可以直接手动启动。 [root@localhost mysql]#service mysqld start Starting MySQL.. SUCCESS! j. 运行客户端程序mysql,在mysql/bin目录中,测试能否连接到mysqld。 [root@localhost 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) 2000, 2012,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. Type '\c' to clear the current input statement. mysql> quit Bye *此时会出现mysql>命令提示符,可以输入sql语句,输入quit或exit退出。为了避免每次都输入mysql的全路径/usr/local/mysql/bin/mysql,可将其加入环境变量中,在/etc/profile最后加入两行命令: MYSQL_HOME=/usr/local/mysql export PATH=$PATH:$MYSQL_HOME/bin 这样就可以在shell中直接输入mysql命令来启动客户端程序了 [root@localhost 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) 2000, 2012,Oracle and/or its affiliates. All rights reserved. Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other namesmay be trademarks of their respective owners. Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement. mysql> Copy after login 5. RPM安装步骤 a. 检查是否已安装,grep的-i选项表示匹配时忽略大小写 [root@localhost JavaEE]#rpm -qa|grep -i mysql mysql-libs-5.1.61-4.el6.x86_64 可见已经安装了库文件,应该先卸载,不然会出现覆盖错误。注意卸载时使用了--nodeps选项,忽略了依赖关系: [root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps Copy after login b. 安装MySQL的服务器端软件,注意切换到root用户: [root@localhost JavaEE]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm 安装完成后,安装进程会在Linux中添加一个mysql组,以及属于mysql组的用户mysql。可通过id命令查看: [root@localhost JavaEE]#id mysql uid=496(mysql)gid=493(mysql) groups=493(mysql) MySQL服务器安装之后虽然配置了相关文件,但并没有自动启动mysqld服务,需自行启动: [root@localhost JavaEE]#service mysql start Starting MySQL.. SUCCESS! 可通过检查端口是否开启来查看MySQL是否正常启动: [root@localhost JavaEE]#netstat -anp|grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 34693/mysqld Copy after login c. 安装MySQL的客户端软件: [root@localhost JavaEE]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm 如果安装成功应该可以运行mysql命令,注意必须是mysqld服务以及开启: [root@localhost JavaEE]#mysql Welcome to the MySQLmonitor. Commands end with ; or \g. Your MySQL connection idis 1 Server 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> Copy after login d. RPM安装方式文件分布
感谢大家的阅读,希望大家受益良多。 本文转自:https://blog.csdn.net/SuperChanon/article/details/8546254 更多教程:《linux运维》 The above is the detailed content of Two ways to install MySQL on Linux. For more information, please follow other related articles on the PHP Chinese website! Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
![]() Hot AI Tools![]() Undresser.AI UndressAI-powered app for creating realistic nude photos ![]() AI Clothes RemoverOnline AI tool for removing clothes from photos. ![]() Undress AI ToolUndress images for free ![]() Clothoff.ioAI clothes remover ![]() AI Hentai GeneratorGenerate AI Hentai for free. ![]() Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks ago
By DDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks ago
By DDD
Where to find the Crane Control Keycard in Atomfall
3 weeks ago
By DDD
Saving in R.E.P.O. Explained (And Save Files)
1 months ago
By 尊渡假赌尊渡假赌尊渡假赌
![]() Hot Tools![]() Notepad++7.3.1Easy-to-use and free code editor ![]() SublimeText3 Chinese versionChinese version, very easy to use ![]() Zend Studio 13.0.1Powerful PHP integrated development environment ![]() Dreamweaver CS6Visual web development tools ![]() SublimeText3 Mac versionGod-level code editing software (SublimeText3) ![]() Hot Topics
CakePHP Tutorial
![]() ![]() ![]() Linux beginners should master basic operations such as file management, user management and network configuration. 1) File management: Use mkdir, touch, ls, rm, mv, and CP commands. 2) User management: Use useradd, passwd, userdel, and usermod commands. 3) Network configuration: Use ifconfig, echo, and ufw commands. These operations are the basis of Linux system management, and mastering them can effectively manage the system. ![]() DebianSniffer is a network sniffer tool used to capture and analyze network packet timestamps: displays the time for packet capture, usually in seconds. Source IP address (SourceIP): The network address of the device that sent the packet. Destination IP address (DestinationIP): The network address of the device receiving the data packet. SourcePort: The port number used by the device sending the packet. Destinatio ![]() In Debian systems, the log files of the Tigervnc server are usually stored in the .vnc folder in the user's home directory. If you run Tigervnc as a specific user, the log file name is usually similar to xf:1.log, where xf:1 represents the username. To view these logs, you can use the following command: cat~/.vnc/xf:1.log Or, you can open the log file using a text editor: nano~/.vnc/xf:1.log Please note that accessing and viewing log files may require root permissions, depending on the security settings of the system. ![]() This article introduces several methods to check the OpenSSL configuration of the Debian system to help you quickly grasp the security status of the system. 1. Confirm the OpenSSL version First, verify whether OpenSSL has been installed and version information. Enter the following command in the terminal: If opensslversion is not installed, the system will prompt an error. 2. View the configuration file. The main configuration file of OpenSSL is usually located in /etc/ssl/openssl.cnf. You can use a text editor (such as nano) to view: sudonano/etc/ssl/openssl.cnf This file contains important configuration information such as key, certificate path, and encryption algorithm. 3. Utilize OPE ![]() This article will explain how to improve website performance by analyzing Apache logs under the Debian system. 1. Log Analysis Basics Apache log records the detailed information of all HTTP requests, including IP address, timestamp, request URL, HTTP method and response code. In Debian systems, these logs are usually located in the /var/log/apache2/access.log and /var/log/apache2/error.log directories. Understanding the log structure is the first step in effective analysis. 2. Log analysis tool You can use a variety of tools to analyze Apache logs: Command line tools: grep, awk, sed and other command line tools. ![]() The readdir function in the Debian system is a system call used to read directory contents and is often used in C programming. This article will explain how to integrate readdir with other tools to enhance its functionality. Method 1: Combining C language program and pipeline First, write a C program to call the readdir function and output the result: #include#include#include#includeintmain(intargc,char*argv[]){DIR*dir;structdirent*entry;if(argc!=2){ ![]() Warning messages in the Tomcat server logs indicate potential problems that may affect application performance or stability. To effectively interpret these warning information, you need to pay attention to the following key points: Warning content: Carefully study the warning information to clarify the type, cause and possible solutions. Warning information usually provides a detailed description. Log level: Tomcat logs contain different levels of information, such as INFO, WARN, ERROR, etc. "WARN" level warnings are non-fatal issues, but they need attention. Timestamp: Record the time when the warning occurs so as to trace the time point when the problem occurs and analyze its relationship with a specific event or operation. Context information: view the log content before and after warning information, obtain ![]() This article discusses the network analysis tool Wireshark and its alternatives in Debian systems. It should be clear that there is no standard network analysis tool called "DebianSniffer". Wireshark is the industry's leading network protocol analyzer, while Debian systems offer other tools with similar functionality. Functional Feature Comparison Wireshark: This is a powerful network protocol analyzer that supports real-time network data capture and in-depth viewing of data packet content, and provides rich protocol support, filtering and search functions to facilitate the diagnosis of network problems. Alternative tools in the Debian system: The Debian system includes networks such as tcpdump and tshark ![]() |