本文描述了MySQL之—CentOS下以RPM方式安裝MySQL5.5詳細介紹,具有參考價值,以下一起分析下
#http: //dev.mysql.com/downloads/mysql/#downloads
Select Platform 選擇 Oracle & Red Hat Linux 4 & 5
分別下載以下三個檔案(由於我的機器是32位,以下是32位元版本的包,如果你的機器是64位元的請下載64位元版本):
1. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
MySQL Server
2. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Client Utilities
3. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Development Libraries
#使用wget指令使用斷點傳輸的方式將這三個檔案下載
wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.28-1.rhel5.i386.rpm wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.28-1.rhel5.i386.rpm wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.28-1.rhel5.i386.rpm
下載完成後開始安裝:
rpm -ivh MySQL-server-5.5.28-1.rhel5.i386.rpm
rpm -ivh MySQL-client-5.5.28-1.rhel5.i386.rpm
##rpm -ivh MySQL-devel-5.5 .28-1.rhel5.i386.rpm
error: Failed dependencies: libaio.so.1()(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
yum install libaio
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
#說明mysql服務還沒啟動,輸入service mysql start啟動mysql服務service mysql start
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.16 MySQL Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Starting MySQL.... ERROR! The server quit without updating PID file (/var/lib/mysql/lechiexxxxx.pid).
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 121012 15:12:05 mysqld_safe mysqld from pid file /var/lib/mysql/lechiexxxxxx.pid ended
/usr/bin/mysql_install_db
[ERROR] Failed to open log (file './mysql-bin.000004', errno 13)
chown -R mysql:mysql /var/lib/mysql/
/usr/bin/mysqld_safe &
whereis mysql
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
/usr/bin/mysqladmin -u root password 新密码XXXXX
mysql -u root –p新密码XXXXX
/etc/init.d/mysql start
或
/etc/rc.d/init.d/mysql start
#2、停止
3、自動啟動
/sbin/chkconfig –list
2)把MySQL加入到你係統的啟動服務群組裡面去
/sbin/chkconfig – add mysql
3)把MySQL從啟動服務群組裡面刪除。
/sbin/chkconfig – del mysql
【更改MySQL目錄】
假如要把目錄移到/home/data下需要進行下面幾步:
#1、home目錄下建立data目錄
mkdir data
記得賦予權限:
chown -R mysql:mysql /home/data
2、把MySQL服務程序停掉:
3、把/var/lib/mysql整個目錄移到/home/data
這樣就把MySQL的資料檔移到了/home/data/mysql下
4、找到my.cnf設定檔
拷貝其中一個到/etc/並改名為my.cnf)。指令如下:
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。
修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值
为:/home/mysql/mysql.sock 。操作如下:
vi my.cnf ##用vi工具编辑my.cnf文件,找到下列数据修改之 # The MySQL server [mysqld] port = 3306 #socket = /var/lib/mysql/mysql.sock ##原内容,为了更稳妥用“#”注释此行 socket = /home/data/mysql/mysql.sock #加上此行
最后,需要修改MySQL启动脚本/etc/rc.d/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存
放路径:home/data/mysql。
vi /etc/rc.d/init.d/mysql #datadir=/var/lib/mysql##注释此行 datadir=/home/data/mysql ##加上此行
/etc/rc.d/init.d/mysql start
或用reboot命令重启Linux
如果工作正常移动就成功了,否则对照前面的7步再检查一下。
处于安全考虑,Mysql默认是不允许远程访问的,可以使用下面开启远程访问
//赋予任何主机访问数据的权限mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION //使修改生效mysql>FLUSH PRIVILEGES
如果依然不能远程访问的话,那就很可能防火墙的原因了,可以在防火墙中开启3306端口或者干脆关掉防火墙。
以上是MySQL之—CentOS下以RPM方式安裝MySQL5.5詳細介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!