search
HomeDatabaseMysql TutorialRHEL下安装MySQL

1.到mysql的网站(必须到官方网站下载,防止数据被修改,纂改过)下载四个必须rpm 安装包:http://dev.mysql.com/downloads/mysql/5.0

1.到mysql的网站(必须到官方网站下载,防止数据被修改,纂改过)下载四个必须rpm 安装包:
#linux-rhel5-ia64-rpms

MySQL-client-5.1.16-0.glibc23.i386.rpm
MySQL-devel-5.1.16-0.glibc23.i386.rpm
MySQL-server-5.1.16-0.glibc23.i386.rpm
MySQL-shared-5.1.16-0.glibc23.i386.rpm

2. 通过ssh远程控制工具传到服务器上,放在适当的目录下(如:/opt/mysql/mysql5.1.16)
3.进入目录(/opt/mysql/mysql5.1.16)下安装msyql:
rpm 文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是 –ivh ,其中i表示将安装指定的rmp软件包,V表示安装时的详细信息,h表示在安装期间出现"#"符号来显示目前的安装过程。这个符号将持续到安装完成后才停止。

[root@qudee mysql5.1.16]# rpm –ivh MySQL-client-5.1.16-0.glibc23.i386.rpm
[root@qudee mysql5.1.16]# rpm –ivh MySQL-devel-5.1.16-0.glibc23.i386.rpm
[root@qudee mysql5.1.16]# rpm –ivh MySQL-shared-5.1.16-0.glibc23.i386.rpm
[root@qudee mysql5.1.16]# rpm –ivh MySQL-server-5.1.16-0.glibc23.i386.rpm

 显示如下信息

warning: MySQL-server-5.1.16-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost password 'new-password'
See the manual for more instructions.

NOTE: If you are upgrading from a MySQL the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

Support MySQL by buying support/licenses athttps://order.mysql.com
Starting MySQL...................................[失败]

4.查看已安装的包
[root@qudee mysql5.1.20]# rpm -qa | grep -i mysql
或者 [root@qudee mysql5.1.20]# rpm -qa | grep mysql

MySQL-devel-5.1.20-0.glibc23
MySQL-shared-5.1.20-0.glibc23
MySQL-client-5.1.20-0.glibc23
MySQL-server-5.1.20-0.glibc23

5.查看[root@qudee /]# locate mysql.server 的路径
/usr/share/man/man1/mysql.server.1.gz
/usr/share/mysql/mysql.server
复制并更名 [root@qudee /]#cp /usr/share/mysql/mysql.server /etc/init.d/mysqld
6.查看[root@qudee /]# locate my-huge.cnf 的路径
/usr/share/doc/MySQL-server-5.1.16/my-huge.cnf
/usr/share/mysql/my-huge.cnf
复制并更名[root@qudee /]#cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
7.启动服务:
service mysqld start
Starting MySQL [ OK ]
启动成功!恭喜~~~
8.编辑vi /etc/my.cnf 这个文件,设置字符集,支持国际化.

default-character-set=utf8 //在此添加字符集
# Here follows entries for some specific programs

# The MySQL server
[mysqld] port = 3306
#socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 384M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M


default-character-set=utf8 //在此添加字符集
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 16

先按Esc, 再同时按Shift + ; 再输入wq! (推出并保存)
呵呵! 字符集就配置好了~~~
9.MySQL默认的数据文件存储目录为/var/lib/mysql。假如要把目录移到/qudeedata/dbdata/mysql5.1.16下需要进行下面几步:
(1)、/qudeedata/dbdata目录下建立mysql5.1.16目录
cd /qudeedata/dbdata
mkdir mysql5.1.16
(2)、把MySQL服务进程停掉:
service mysqld stop
(3)、把/var/lib/mysql整个目录移到/qudeedata/dbdata/mysql5.1.16
mv /var/lib/mysql /qudeedata/dbdata/mysql5.1.16
这样就把MySQL的数据文件移动到了/qudeedata/dbdata/mysql5.1.16 下
(4)、编辑MySQL的配置文件/etc/my.cnf
为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值为:
/qudeedata/dbdata/mysql5.1.16/mysql/mysql.sock 。操作如下:
命令: vi  my.cnf    (用vi工具编辑my.cnf文件,找到下列数据修改之)
# The MySQL server
[mysqld]
port   = 3306
#socket  = /var/lib/mysql/mysql.sock(原内容,为了更稳妥用"#"注释此行)
socket  = /qudeedata/dbdata/mysql5.1.16/mysql/mysql.sock   (加上此行)
(5)、修改MySQL启动脚本/etc/rc.d/init.d/mysqld
最后,需要修改MySQL启动脚本/etc/rc.d/init.d/mysqld,把其中datadir=/var/lib/mysql一行中,,等号右边的路径改成你现在的实际存放路径:
/qudeedata/dbdata/mysql5.1.16。
[root@test1 etc]# vi /etc/rc.d/init.d/mysqld
#datadir=/var/lib/mysql    (注释此行)
datadir=/qudeedata/dbdata/mysql5.1.16   (加上此行)
10、自动启动
1)察看mysql是否在自动启动列表中
[root@qudee /]# chkconfig –list
2)把MySQL添加到你系统的启动服务组里面去
[root@qudee /]# chkconfig – add mysql
11.测试通过命令是否能够启动,停止,重启
结果:

[root@qudee /]# service mysqld start
Starting MySQL [ OK ]
[root@qudee /]# service mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL [ OK ]
[root@qudee /]# service mysqld stop
Shutting down MySQL... [ OK ]
[root@qudee /]# /etc/init.d/mysqld start
Starting MySQL [ OK ]
[root@qudee /]# /etc/init.d/mysqld restart
Shutting down MySQL... [ OK ]
Starting MySQL [ OK ]
[root@qudee /]# /etc/init.d/mysqld stop
Shutting down MySQL.. [ OK ]

证明,成功安装mysql.注:还可以通过添加,查询,删除数据库中的数据进行操作.
12.完成安装!

linux

Statement
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
How to use MySQL functions for data processing and calculationHow to use MySQL functions for data processing and calculationApr 29, 2025 pm 04:21 PM

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

An efficient way to batch insert data in MySQLAn efficient way to batch insert data in MySQLApr 29, 2025 pm 04:18 PM

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

Steps to add and delete fields to MySQL tablesSteps to add and delete fields to MySQL tablesApr 29, 2025 pm 04:15 PM

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

How to analyze the execution plan of MySQL queryHow to analyze the execution plan of MySQL queryApr 29, 2025 pm 04:12 PM

Use the EXPLAIN command to analyze the execution plan of MySQL queries. 1. The EXPLAIN command displays the execution plan of the query to help find performance bottlenecks. 2. The execution plan includes fields such as id, select_type, table, type, possible_keys, key, key_len, ref, rows and Extra. 3. According to the execution plan, you can optimize queries by adding indexes, avoiding full table scans, optimizing JOIN operations, and using overlay indexes.

How to use MySQL subquery to improve query efficiencyHow to use MySQL subquery to improve query efficiencyApr 29, 2025 pm 04:09 PM

Subqueries can improve the efficiency of MySQL query. 1) Subquery simplifies complex query logic, such as filtering data and calculating aggregated values. 2) MySQL optimizer may convert subqueries to JOIN operations to improve performance. 3) Using EXISTS instead of IN can avoid multiple rows returning errors. 4) Optimization strategies include avoiding related subqueries, using EXISTS, index optimization, and avoiding subquery nesting.

How to configure the character set and collation rules of MySQLHow to configure the character set and collation rules of MySQLApr 29, 2025 pm 04:06 PM

Methods for configuring character sets and collations in MySQL include: 1. Setting the character sets and collations at the server level: SETNAMES'utf8'; SETCHARACTERSETutf8; SETCOLLATION_CONNECTION='utf8_general_ci'; 2. Create a database that uses specific character sets and collations: CREATEDATABASEexample_dbCHARACTERSETutf8COLLATEutf8_general_ci; 3. Specify character sets and collations when creating a table: CREATETABLEexample_table(idINT

How to uninstall MySQL and clean residual filesHow to uninstall MySQL and clean residual filesApr 29, 2025 pm 04:03 PM

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

How to rename a database in MySQLHow to rename a database in MySQLApr 29, 2025 pm 04:00 PM

Renaming a database in MySQL requires indirect methods. The steps are as follows: 1. Create a new database; 2. Use mysqldump to export the old database; 3. Import the data into the new database; 4. Delete the old database.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),