How to install new version of mysql

来源:互联网 发布:淘宝卖假货的美妆店 编辑:程序博客网 时间:2024/04/30 09:22

1. mysql在linux下的编译和安装
[root@localhost zieckey]# mkdir /usr/local/mysql
[root@localhost zieckey]# cp mysql-4.0.12.tar.gz /home/
[root@localhost root]# cd /home/
解压
[root@localhost home]# tar zxvf mysql-4.0.12.tar.gz
[root@localhost home]# cd mysql-4.0.12
配置,生成Makefile
[root@localhost mysql-4.0.12]# ./configure --prefix=/usr/local/mysql --without-debug --with-extra-charsets=gb2312 --enable-assembler --without-isam --without-innodb --with-pthread --enable-thread-safe-client
编译
[root@localhost mysql-4.0.12]# make
安装
[root@localhost mysql-4.0.12]# make install

[root@localhost mysql-4.0.12]# scripts/mysql_install_db

创建一个数据库管理员
[root@localhost mysql-4.0.12]# groupadd mysql
[root@localhost mysql-4.0.12]# useradd -g mysql mysql


改变权限。
[root@localhost mysql]# chown -R root /usr/local/mysql
[root@localhost mysql]# chown -R mysql /usr/local/mysql/var
[root@localhost mysql]# chgrp -R mysql /usr/local/mysql



配置环境变量,以便于编程
[root@localhost mysql-4.0.12]# cd /usr/local/mysql/bin/
[root@localhost bin]# export PATH=$PATH:/usr/local/mysql/bin/
[root@localhost bin]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql/
[root@localhost bin]# env


启动mysql服务器
[root@localhost root]# cd /usr/local/mysql/bin/
[root@localhost bin]# ./mysqld_safe -u mysql&
Starting mysqld daemon with databases from /usr/local/mysql/var
查看是否启动了
[root@localhost root]# pgrep mysql
 

[How to install new version of mysql]

Please refer to Tips to download relative mysql software. Here, I guess that we have acquired mysql-standard-5.0.19-linux-i686.tar.gz.

1) Add a login user and group fro ‘mysqld’ to run. If system has existed 
relative user name and group name, these operations will be skipped.
Of course, if you do it again, it is no problems.
$groupadd mysql
$useradd –g mysql mysql
2) Unpack mysql-standard-5.0.19-linux-i686.tar.gz into /usr/local directory
#cd /usr/local
#tar xvzf ./mysql-standard-5.0.19-linux-i686.tar.gz ./
#ln ./ mysql-standard-5.0.19-linux-i686 ./mysql
3) Install MySQL
#cd ./mysql
#scripts/mysql_install_db --user=mysql
4) Backup old MySQL’s configuration and commands
#mv /etc/my.cnf /etc/old_cnf
#mv /etc/init.d/mysqld /etc/init.d/old_mysqld
#cp –rf /usr/bin /usr/old_bin
#cd /usr/bin
#rm my*
#rm my*.*
5) Configure new MySQL. There are four configuring files at less in 
the support-files directory.
‘my-huge.cnf’       for huge database
‘my-large.cnf’      for large database
‘my-medium.cnf’     for medium database
‘my-small.cnf’      for small database
‘my-innodb-heavy-4G.cnf’ for innodb database, in normal case, innodb 
will be forbidden. If you are interested in it, please visit ]
http://www.innodb.com/index.php to realise more information in details.
#cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
#vim /etc/my.cnf 
//set basedir=/usr/local/mysql
//set datadir=/usr/local/mysql/data
#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
6) Change the ownership of program binaries to `root' and ownership
of the ‘data’ directory to the user that you run `mysqld' as. 
Assuming that you are located in the installation directory
(`/usr/local/mysql'), the commands look like this:
#chown -R root  .
#chown -R mysql data
#chgrp -R mysql .
7) Add the directory of MySQL into $PATH envorinment. 
Edit ~/.bash_profile and append the following line.
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin 
8) Reboot linux
#reboot

 

[Tips]

Where to download the lastest version of mysql?

You can visit http://dev.mysql.com/downloads/ to find the latest version of mysql to download it. mysql-standard-5.0.19-linux-i686.tar.gz  is download from http://dev.mysql.com/downloads/mysql/5.0.html below the tag of ‘Linux(non RPM package)downloads(platform notes)’. If your CPU and HDD are faster and larger, the maximum one is the better choice. Some persons like DIY(Do It By yourself), and ‘Source downloads’ tag should be hot point for them. I am long-winded man, and DIYs had better read README carefully before compiling and installing. If they are unfavor to read English, I recommend a website: http://www.chinaunix.net/jh/17/178508.html which is very good for beginner to configure and install mysql. I hope that it will exist when you visit it!

 

How to query current RPM package of mysql?

# rpm -qa | egrep 'mysql'

mysql-jdbc-3.0.8-2

mysql-server-3.23.58-9

php-mysql-4.3.4-11

mysql-devel-3.23.58-9

freeradius-mysql-0.9.3-4

libdbi-dbd-mysql-0.6.5-8.1

mysql-3.23.58-9

mysql-jdbc-tomcat-3.0.8-2

mod_auth_mysql-20030510-4.1

mysql-bench-3.23.58-9

 

How to uninstall RPM package?

Please use the following command, ‘-e’ means erasing operation. ‘nodeps’ means not to check dependencies before uninstalling the packages, and it is forced.

#rpm {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--repackage] [--test] PACKAGE_NAME ...

If you want to know more details about ‘rpm’ command, please use #man rpm or #info rmp to obtain more information.

 

How to start/stop/restart mysql server?

#service mysqld start/stop/restart


How to change ‘mysql.sock’ into other directory?

#cd /etc

#vi my.cnf

Modify ‘sokcet’ key’s value, for example:

[client]

socket          = /var/lib/mysql/mysql.sock

[mysqld]

socket          = /var/lib/mysql/mysql.sock

Generate ‘mysql.sock’ file and relative directories

#service mysqld restart

#cd /var/lib

Change group from ‘root’ to ‘mysql’

#chgrp mysql ./mysql

Make other groups can connect mysql server by ‘mysql.sock’

#chmod +x ./mysql

[User Manual For Mysql 5.0]

http://dev.mysql.com/doc/refman/5.0/en/index.html

 

3、mysql目录

数据库目录:/var/lib/mysql/ (自己可以修改etc/mysql/my.cnf更改存放数据的目录)
配置文件:/usr/share/mysql
相关命令:/usr/bin(mysqladmin mysqlbrowser mysqldump等命令)

4、配置c API的环境
前面都好说,就是这个,苦苦找了两个点才找到。

  apt-get install libmysqlclient15-dev

安装完以后,会在/usr/include/mysql/目录下找到mysql.h这个头文件
并且会在/usr/lib/mysql/找到mysql的一些动态或者是静态的库文