預(yù)處理:
rpm -q mysql;
rpm -e --nodeps mysql;
1.groupadd mysql
2.useradd -g mysql mysql
3.下載 mysql-standard-5.0.21-linux-i686-glibc23.tar.gz
4.放到/usr/local
5.tar -xvzf mysql-standard-5.0.21-linux-i686-glibc23.tar.gz
6.ln -s mysql****** mysql (將解壓后的mysql目錄軟連接成mysql,或者直接更名為mysql也可,只是以后沒(méi)辦法看mysql版本)
7.chown -R mysql.mysql mysql (一定要帶-R)
8.執(zhí)行一下./scripts/mysql_install_db --user=mysql (注意一定要在/usr/local/mysql目錄下執(zhí)行該命令,不能到scripts下執(zhí)行mysql_install_db,目錄結(jié)構(gòu)有關(guān)系)
9.這時(shí)將在/usr/local/mysql/data 生成一個(gè)用戶(hù)數(shù)據(jù)庫(kù)(mysql)和一個(gè)test數(shù)據(jù)庫(kù) (一定要確認(rèn))
10.把/etc/my.cnf文件改名或刪掉
11.cd /usr/local/mysql/support-file
12.cp mysql.server /etc/rc.d/init.d/mysqld
13.cp my-huge.cnf ../data
14.所有操作都是用root的
啟動(dòng)mysql用以下兩種方式均可
(1)/etc/rc.d/init.d/mysqld start
(2)service mysqld start
15.修改root密碼
mysqladmin -u root password 'new-password'
16.創(chuàng)建用戶(hù),后付所有權(quán)限
1 用于程序發(fā)布中,指定數(shù)據(jù)庫(kù),指定用戶(hù),權(quán)限小不影響工作(程序和數(shù)據(jù)庫(kù)服務(wù)器在同一臺(tái)機(jī)器上,否則用指定IP或域名)
grant select, insert, update, delete on notebase.* to nb@localhost identified by 'nb123';
不推薦使用%,這樣所有的IP都能連接,不過(guò)只能對(duì)notebase操作
grant select, insert, update, delete on notebase.* to nb@"%" identified by 'nb123';
2 用于程序開(kāi)發(fā)中,讓指定開(kāi)發(fā)人員的機(jī)器有最高訪(fǎng)問(wèn)權(quán)限
grant ALL PRIVILEGES on *.* to root@"10.0.0.11" Identified by "root" WITH GRANT OPTION;
flush privileges
17.進(jìn)入mysql
mysql -uroot -p770511
18.關(guān)閉數(shù)據(jù)庫(kù):
mysqladmin -uroot -pxxxx -hxxxxxxxxx shutdown
19(
啟動(dòng),關(guān)閉,連接數(shù)據(jù)庫(kù)時(shí)可能出現(xiàn) 無(wú)法找到/usr/lib/mysql/mysql.sock錯(cuò)誤,這是因?yàn)椋瑱C(jī)器本身自帶的mysql 把socket通信文件指定在/usr/lib/mysql/mysql.sock,這時(shí)只要將本身自帶的mysql和mysqladmin命令文件刪除,并把/usr/local/mysql/bin置入PATH環(huán)境變量即可正常使用)
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 localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/local/mysql/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.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!