Linux+Apache2+Mysql+Php安裝配置及其mysql字元設定錯誤
在此Linux下全新安裝配置Mysql、Apache2、PHP,解決在安裝Mysql時出現的報錯:Character set 'gbk' is not a compiled character set and is not specified in the /usr/local/mysql/share/mysql/charsets/Index.xml' file
在安裝mysql後可以在下面目錄找到mysql的相關安裝配置資訊說明/usr/local/mysql/info/mysql.info
[@more@]在此Linux下全新安裝配置Mysql、Apache2、PHP,解決在安裝Mysql時出現的報錯:Character set 'gbk' is not a compiled character set and is not specified in the /usr/local/mysql/share/mysql/charsets/Index.xml' file
在安裝mysql後可以在下面目錄找到mysql的相關安裝配置資訊說明/usr/local/mysql/info/mysql.info
############################################
1.檢查系統及核心狀態
[root@app /]# cat /etc/issue
Red Hat Enterprise Linux AS release 4 (Nahant)
Kernel r on an m
[root@app /]# cat /proc/version
Linux version 2.6.9-5.ELsmp () (gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)) #1 SMP Wed Jan 5 19:30:39 EST 2005
[root@app /]# uname -r
2.6.9-5.ELsmp
1.1檢視CPU及MEM
[root@app /]# grep "model name" /proc/cpuinfo
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
[root@app /]# grep MemTotal /proc/meminfo
MemTotal: 4147280 kB
1.2作業系統位數
[root@app /]# getconf LONG_BIT
32
[root@app /]# ldd /sbin/mii-tool
libc.so.6 => /lib/tls/libc.so.6 (0x0097e000)
/lib/ld-linux.so.2 (0x00965000)
2.準備好安裝包
mysql-5.0.45.tar.gz
mysql-5.0.45-linux-i686-glibc23.tar.gz
httpd-2.2.4.tar.gz
php-4.4.7.tar.gz
3.進行安裝配置
3.1檢查系統是否已經安裝相應的Mysql,php,apache軟體包
# rpm -qa | grep mysql 和# rpm -qa | grep MySQL
rpm -q -a|grep -i mysql
rpm -q -a|grep -i httpd
rpm -q -a|grep -i php
如果沒有返回以mysql或MySQL打頭的資訊,則說明沒有安裝.如果已經安裝,則可以直接使用或更換新版本
解除安裝方法:
# rpm -e mysql-xxxxxx
# rpm -e httpd-xxxxxx
# rpm -e php-xxxxxx
遇到依賴性問題而無法解除安裝,可以使用--nodeps或—force強制解除安裝.不過最好慎用.
rpm -e --nodeps httpd
rpm -e --nodeps php
3.2進行安裝
cp mysql-5.0.45.tar.gz /tmp
cp mysql-5.0.45-linux-i686-glibc23.tar.gz /tmp
cp httpd-2.2.4.tar.gz /tmp
cp php-4.4.7.tar.gz /tmp
3.3 Mysql-5.0.45版本的安裝
cd /tmp
tar xvfz mysql-5.0.45.tar.gz
cd /mysql-5.0.45
./configure --prefix=/usr/local/mysql --with-extra-charsets=gbk --with-charset=gbk --sysconfdir=/etc --localstatedir=/var/lib/mysql
make
make install
指定字元型別為gbk 進行編譯安裝
#prefix=/usr/local/mysql mysql安裝的目標目錄
#sysconfdir=/etc my.cnf配置檔案的路徑
#localstatedir=/var/lib/mysql 資料庫存放的路徑
安裝完以後要初始化資料庫,當然你是升級的話不用做這步;
/usr/local/mysql/bin/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h app.shunde.gov.cn password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
資訊有提示將
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqladmin -u root password '******'
啟動Mysql進行測試
/etc/rc.d/init.d/mysqld status
/etc/rc.d/init.d/mysqld start
如果大家還是不能啟動不了的話,那就用我的比較繁瑣的許可權的設定,反正我每次都是這麼做的,一般不會有問題,見下:
chown -R root /usr/local/mysql
chgrp -R mysql /usr/local/mysql
chown -R root /usr/local/mysql/bin
chgrp -R mysql /usr/local/mysql/bin
chgrp -R mysql /var/lib/mysql
chmod 777 /var/lib/mysql
chown -R root /var/lib/mysql/mysql
chgrp -R mysql /var/lib/mysql/mysql
chmod 777 /var/lib/mysql/mysql
chown -R root /var/lib/mysql/mysql/*
chgrp -R mysql /var/lib/mysql/mysql/*
chmod 777 /var/lib/mysql/mysql/*
chmod 777 /usr/local/mysql/lib/mysql/libmysqlclient.a
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
其下可能還有如下錯誤出現
/usr/local/mysql/bin/mysqladmin: Character set 'gbk' is not a compiled character set and is not specified in the
'/usr/local/mysql/share/mysql/charsets/Index.xml' file
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't initialize character set gbk (path: /usr/local/mysql/share/mysql/charsets/)
現在找到該解決辦法是打mysql-5.0.45-linux-i686-glibc23.tar.gz補丁包
cd /tmp
tar xvfz mysql-5.0.45-linux-i686-glibc23.tar.gz
cp /usr/local/mysql /usr/local/old_mysql
rm -rf /usr/local/mysql
cp mysql-5.0.45-linux-i686-glibc23 /usr/local/mysql
重新啟動Mysql,沒有出現gbk的報錯
繼續修改/etc/my.cnf的引數配置,將default-character-set=gbk增加在如下位置
[client]
default-character-set=gbk
[mysqld]
default-character-set=gbk
重新啟動Mysql
/etc/rc.d/init.d/mysqld restart
登入Mysql
/usr/local/mysql/bin/mysql -uroot -p******
mysql> SHOW VARIABLES LIKE 'char%';
+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/mysql/charsets/ |
+--------------------------+----------------------------------------+
8 rows in set (0.01 sec)
如上圖所示改成所需字元型別gbk
[root@app bin]# /usr/local/mysql/bin/mysqlshow -uroot -p******
[root@app bin]# /usr/local/mysql/bin/mysqlcheck -A -uroot -p******
3.3.1轉移mysql資料,先從舊庫匯出成*.sql,然後匯入到新庫
[root@house ~]# /usr/local/mysql/bin/mysqldump -uroot -p****** db1 >/opt/db1_bakup.20080304.sql
[root@house ~]# /usr/local/mysql/bin/mysqldump -uroot -p****** db2 >/opt/db2_bakup.20080304.sql
[root@house ~]# /usr/local/mysql/bin/mysql -uroot -p****** db1 < /opt/db1_bakup.20080304.sql
[root@house ~]# /usr/local/mysql/bin/mysql -uroot -p****** db2 < /opt/db2_bakup.20080304.sql
3.4安裝Apache-2.2.4
cd /tmp
tar xvfz httpd-2.2.4.tar.gz
cd /httpd-2.2.4
./configure --prefix=/usr/local/apache2 --enable-module=so --enable-module=rewrite --enable-shared=max
--啟動apache
/usr/local/apache2/bin/apachectl start
--關閉apache
/usr/local/apache2/bin/apachectl stop
3.5安裝php-4.4.7
cd /tmp
tar xvfz php-4.4.7.tar.gz
cd / php-4.4.7
[root@app php-4.4.7]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --enable-force-cgi-redirect --with-freetype-dir=/usr --with-png-
dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --with-gdbm --with-gettext --with-iconv --with-jpeg-dir=/usr --with-png --with-zlib --with-xml --
enable-calendar --with-apxs2=/usr/local/apache2/bin/apxs
make
make install
3.5.1 配置php.ini
/usr/local/php/lib/php.ini
4.進行系統測試
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/216109/viewspace-1000728/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 安裝常見錯誤MySql
- Linux 安裝 MySQL 8 的錯誤整理(待續)LinuxMySql
- cocoapods安裝錯誤
- MySQL字元編碼設定方法MySql字元
- MySQL安裝配置MySql
- 寶塔皮膚安裝配置檔案有錯誤
- MySql8以上安裝失敗錯誤database filedMySqlDatabase
- ubuntu安裝了mysql8,設定遠端連線後,密碼錯誤的問題解決UbuntuMySql密碼
- Linux配置JavaEE環境 Linux中安裝JDK、Tomcat、mysql 設定Tomcat自啟動、設定mysql自啟動LinuxJavaJDKTomcatMySql
- onethink安裝提示錯誤
- mysql安裝及配置MySql
- 【MySQL】安裝與配置MySql
- MySQL安裝與配置MySql
- 安裝golang tour,提示錯誤Golang
- Hadoop安裝錯誤總結Hadoop
- Ubuntu 安裝包時提示錯誤E: Unable to locate package mysql-server錯誤 解決辦法UbuntuPackageMySqlServer
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- MySQL-安裝配置篇MySql
- 【Mysql】Windows下安裝和配置MysqlMySqlWindows
- Mysql for Linux安裝配置之—— rpm(bundle)安裝MySqlLinux
- Mysql for Linux安裝配置之—— 原始碼安裝MySqlLinux原始碼
- MySQL安裝之二_安裝配置泥潭版MySql
- PHP安裝後錯誤處理PHP
- linux安裝thefuck報gcc錯誤LinuxGC
- 安裝.NET Core遇到的錯誤
- MySQL安裝之一_安裝配置順利版MySql
- Python錯誤:PyCharm 安裝出錯 Internal error,please。。。PythonPyCharmError
- iis7.5錯誤 配置錯誤
- MySQL - 安裝時的安全配置MySql
- Ubuntu 18.04 安裝配置 MySQL 5.7UbuntuMySql
- LNMP--mysql php安裝配置LNMPMySqlPHP
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- Mysql安裝及基礎配置MySql
- Ubuntu安裝MySQL如何設定資料庫密碼UbuntuMySql資料庫密碼
- MySQL的安裝以及基本的管理命令和設定MySql
- windows 2019 net 3.5 安裝錯誤提示Windows
- MacOs 安裝擴充套件錯誤列表Mac套件
- WordPress 線上安裝或更新錯誤
- Mysql for Linux安裝配置之——二進位制安裝MySqlLinux