Linux下MySQL源码安装及问题解决
准备MySQL的源码,版本号为Mysql-5.0.20a.tar.gz,当然其它的也行,只做为测试.Linux用Red hat Linux as 4.安装步骤:1.解压Mysql-5.
准备MySQL的源码,版本号为Mysql-5.0.20a.tar.gz,当然其它的也行,只做为测试.Linux用Red Hat Linux as 4.
安装步骤:
1.解压Mysql-5.0.20a.tar.gz.
命令: tar -zxvf Mysql-5.0.20a.tar.gz
2.配置 Mysql
命令:./configure --prefix=/usr/local/mysql [--with-charset=gbk]
说明:安装到/usr/local/mysql(最好先创建该目录)下,语言用gbk(可选项).当然用别的也行,还有其它参数可以查看相关文档.
3.编译,安装
命令:
make //如果第一次make错误,,要先make clean再make
make install
这两个命令发的时间较长.
4.创建用户和组.
groupadd Mysql
useradd -g Mysql Mysql
5.进入Mysql目录.创建var目录.并把./share/mysql/my-medium.cnf 拷到mysql目录下并改名为my.cnf.
>mkdir var
>mv share/mysql/my-medium.cnf my.cnf
6.配置my.cnf
配置主要把安装的目录的那几项打开就行.
改动如下:
[client]
#password = your_password
port = 3306
socket = /tmp/Mysql3306.sock
# The Mysql server
[Mysqld]
port = 3306
socket = /tmp/Mysql3306.sock
打开下面几项
innodb_data_home_dir = =/usr/local/mysql/var/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = =/usr/local/mysql/var/
innodb_log_arch_dir = =/usr/local/mysql/var/
//我第一次configure时--prefix=后面的路径误写成/usr/lcoal/mysql 发现后删除该安装目录,再次安装时发现安装过程报错(又到/usr/lcoal/mysql下读文件),打开配置文件发现该选项中的路径都被系统改为/usr/lcoal/mysql/var --解决办法改正该路径,同时到mysql源码文件下执行make clean 再次make 就ok了
7.安装数据库
命令:./bin/mysql_install_db --defaults-file=/usr/local/mysql/my.cnf --user=Mysql
说明:必须用参数--defaults-file指定my.cnf,否则系统用默认的/etc/my.cnf.
8.安装完后,可以看到Mysql/var目录下有数据文件,然后在/usr/local/mysql 用下面命令设置权限:
shell> chown -R root .
shell> chown -R Mysql var
shell> chgrp -R Mysql .
9.启动数据库.
./bin/Mysqld_safe --defaults-file=/test/Mysql/my
.cnf --user=Mysql &
10.进入数据库.
./bin/Mysql -u root --socket=/tmp/Mysql3306 --defaults-file=/test/Mysql/my.cnf
默认时没有密码,当然如果你删除/etc/my.cnf,可以不要后面的--defaults-file=/test/Mysql/my.cnf
./bin/Mysql -u root --socket=/tmp/Mysql3306 也就行了,原因大家应该知道吧!
//如果系统已经安装的有mysql了,这时执行mysql会发现系统还是运行的原来的mysql
shell#mysql
这时需要停止旧mysql 然后执行如下命令:
#cd /usr/bin
#rm -rf mysql
#ln -s /usr/local/mysql/bin/mysql ./mysql
这时再次执行mysql就会执行新版本的mysql;由于以后可能会用到mysql的相关库及头文件建议执行如下操作:
#cp -r /usr/local/mysql/include/mysql/* /usr/include/mysql
11.设为服务并自启动
对于设置为服务只要把Mysql/share/Mysql/Mysql.server放到/etc/init.d/下改名为Mysql
命令:
mv share/Mysql/Mysql.server /etc/init.d/Mysql
chmod 775 /etc/init.d/Mysql
chkconfig --add Mysql
总结,这只是安装了一个3306端口的Mysql,如果要在装一个msyql,步骤一样,只要改动my.cnf文件的内容.
[client]
#password = your_password
port = 3310
socket = /tmp/Mysql3310.sock
# The Mysql server
[Mysqld]
port = 3310
socket = /tmp/Mysql3310.sock
ok!就到这吧!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
