1.1
地址:http://www.mysql.com/downloads/mysql/5.5.html#downloads
版本:5.1.68
平臺:linux general
Generic Linux (glibc 2.3) (x86, 64-bit), RPM Package
版本:MySQL Server
(MySQL-server-5.1.68-1.glibc23.x86_64.rpm)
注:這個不是新版,但倒是我之前應用的版本,推敲兼容性,應用該版本。
1.2? 搜檢老版本并卸載
http://blog.sina.com.cn/s/blog_48d5933f0100ts7t.html
1、查找以前是否裝有mysql
號令:rpm -qa|grep -i mysql
可以看到mysql的兩個包:
mysql-4.1.12-3.RHEL4.1
mysqlclient10-3.23.58-4.RHEL4.1
2、刪除mysql
刪除號令:rpm -e --nodeps 包名
( rpm -ev mysql-4.1.12-3.RHEL4.1 )
3、刪除老版本mysql的開辟頭文件和庫
號令:rm -fr /usr/lib/mysql
rm -fr /usr/include/mysql
重視:卸載后/var/lib/mysql中的數據及/etc/my.cnf不會刪除,若是斷定沒用后就手工刪除
rm -f /etc/my.cnf
rm -fr /var/lib/mysql
1.3? 安裝
[root@localhost soft]# rpm -ivh MySQL-server-5.1.68-1.glibc23.x86_64.rpm
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.localdomain password new-password
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.? This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
Starting MySQL. SUCCESS!
[root@localhost soft]# mysql
-bash: /bin/mysql: 沒有那個文件或目次
1.4? 登錄MySQL
號令是mysql, mysql 的應用語法如下:
mysql [-u username] [-h host] [-p[password]] [dbname]
username 與 password 分別是 MySQL 的用戶名與暗碼,mysql的初始經司帳號是root,沒有暗碼,重視:這個root用戶不是Linux的體系用戶。MySQL默認用戶是root,因為初始沒有暗碼,第一次進時只需鍵入mysql即可。
MySQL默認沒有暗碼,安裝完畢增長暗碼的首要性是不問可知的。
1、號令
usr/bin/mysqladmin -u root password new-password
格局:mysqladmin -u用戶名 -p舊暗碼 password 新暗碼
2、例子
例1:給root加個暗碼123456。
鍵入以下號令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
注:因為開端時root沒有暗碼,所以-p舊暗碼一項就可以省略了。
3、測試是否批改成功
1)不消暗碼登錄
[root@test1 local]# mysql
ERROR 1045: Access denied for user: root@localhost (Using password: NO)
顯示錯誤,申明暗碼已經批改。
2)用批改后的暗碼登錄
[root@test1 local]# mysql -u root -p
1.5? 設置收集接見
mysql>grant all privileges on . to root@% identified by andrew’ ;
給來自任何IP地址的用戶user分派可對所稀有據庫的所有表進行所有操縱的權限限,并設定口令為123456。
1.6? 編譯運行mysql法度
gcc -ofile1 file1.c? -lmysqlclient -lpthread -ldl? -lm -I/usr/include/mysql/ -L/usr/lib64/mysql
1.7? 報錯
/bin/ld: cannot find -lmysqlclient
1.7.1? 解決辦法1:(測試可行)
64位Linux體系下,源碼編譯時,有時會無法鏈接libmysqlclient庫:
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
請將Makefile里面的
-L/usr/lib/mysql
改為
-L/usr/lib64/mysql
注明:此處我將-L/usr/lib64/mysql添加進eclipse下的object.mk中。文藝不是炫耀,不是花哨空洞的文字堆砌,不是一張又一張的逆光照片,不是將旅行的意義轉化為名牌包和明信片的物質展示;很多時候它甚至完全不美——它嘶吼、扭曲,它會痛苦地抽搐,它常常無言地沉默。——艾小柯《文藝是一種信仰》