MySQL for linux安裝詳解(mysql-5.1.40-linux-i686-glibc23.tar.gz安裝筆記) 安裝源代碼版本的MySQL 1.首先添加mysql用戶組
shell> groupadd mysql
2.添加mysql用戶,并指定到mysql用戶組
shell> useradd -g mysql mysql
3.解壓縮mysql-version.tar.gz
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf - 4.安裝mysql
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charsets=armscii8,ascii,big5,cp1250,cp1251,cp1256,cp1257,cp850,cp852,cp866,cp932,dec8,eucjpms,euckr,gb2312,gbk,geostd8,greek,hebrew,hp8,keybcs2,koi8r,koi8u,latin1,latin2,latin5,latin7,macce,macroman,sjis,swe7,tis620,ucs2,ujis,utf8 --with-plugins=innodb_plugin shell> make
shell> make install 5.復(fù)制配置文件
shell> cp support-files/my-medium.cnf /etc/my.cnf 6.執(zhí)行mysql系統(tǒng)數(shù)據(jù)庫初始化腳本
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql 7.設(shè)定mysql安裝目錄權(quán)限,設(shè)置owner為mysql
shell> chown -R mysql var
shell> chgrp -R mysql . 8.啟動(dòng)mysql應(yīng)用
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
9.設(shè)置root密碼(數(shù)據(jù)庫的DBA)
shell> bin/mysqladmin -u root password ‘123456’
10.登錄mysql
shell> bin/mysql -u root -p
Enter password:
登錄成功會(huì)看到:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 229
Server version: 5.1.40-log MySQL Community Server (GPL)
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.
mysql>
這時(shí)mysql已經(jīng)裝好了,可以查看數(shù)據(jù)庫了,但在正式使用數(shù)據(jù)庫開發(fā)與部署的時(shí)候還需要做一些工作:
1.設(shè)定配置文件my.cnf 按照需求copy my-***.cnf到/etc/my.cnf 2.修改默認(rèn)字符集utf8 (1).[client]下加入default-character-set=utf8 (2).[mysqld]下加入default-character-set=utf8 #不改動(dòng)存儲(chǔ)引擎的話,3、4步可以略過
3.啟動(dòng)InnoDB引擎的方法如下: 1)關(guān)閉mysql的服務(wù) 2)修改my.ini 將default-storage-engine=INNODB前的注釋(#)去掉 將skip-innodb這行注釋(加上#) 4.配置innodb參數(shù) 1).找到# Uncomment the following if you are using InnoDB tables 去掉innodb_*下的所有# 2).如果安裝mysql的目錄不是默認(rèn)的,則需要修改 # mysql 默認(rèn)安裝目錄為 /usr/local/mysql/ # mysql 默認(rèn)表空間目錄安裝目錄為 /usr/local/mysql/var/ innodb_data_home_dir=/usr/local/database/mysql/var/ innodb_log_group_home_dir=/usr/local/database/mysql/var/ 3).保存后重啟mysql服務(wù)。
5.設(shè)置系統(tǒng)服務(wù) 讓linux啟動(dòng)的時(shí)候就啟動(dòng)mysql服務(wù) shell> cd /usr/local/mysql/
shell> cp support-files/mysql.server /etc/init.d/mysql
shell> chmod 777 /etc/init.d/mysql
shell> chkconfig --add mysql
shell> chkconfig --level 35 mysql on
6.重啟MySQL服務(wù)
shell> service mysql restart
備注: shell> groupadd mysql Configure the release and compile everything:配置和編譯 shell> ./configure --prefix=/usr/local/mysql If you want to set up an option file, use one of those present in shell> cp support-files/my-medium.cnf /etc/my.cnf If you haven`t installed MySQL before, you must create the MySQL shell> bin/mysql_install_db --user=mysql Change the ownership of program binaries to ‘root’ and ownership shell> chown -R mysql var The first command changes the owner attribute of the files to the ‘root’ user. 第一行命令把文件擁有權(quán)給‘root’。The second changes the owner attribute of the data directory to the ‘mysql’ user. 第二行把數(shù)據(jù)目錄擁護(hù)權(quán)給‘mysql’用戶。The third changes the group attribute to the ‘mysql’ group.第三行把組的權(quán)限給‘mysql’組。 After everything has been installed, you should initialize and test your distribution using this command:萬事具備后,你就可以按照下面的命令測(cè)試并運(yùn)行你的MySQL了: shell> /usr/local/mysql/bin/mysqld_safe --user=mysql & 注:文件中的單引號(hào)全應(yīng)該是英文狀態(tài)下輸入的,但是發(fā)布不了,我只好改成中文狀態(tài)下輸入的單引號(hào)了。
mysql 遠(yuǎn)程連接
1.以root用戶登錄mysql后,執(zhí)行如下命令:
grant all privileges on *.* to root@’允許登錄的遠(yuǎn)程機(jī)器ip’ identified by ‘密碼’ 其中,*.*表示該主機(jī)中所有數(shù)據(jù)庫的所有表。(數(shù)據(jù)庫.表) “給某IP地址上登錄的root用戶授予訪問所有數(shù)據(jù)庫中的所有表的所有權(quán)限” 如果想讓所有主機(jī)都可以遠(yuǎn)程連接,則執(zhí)行完步驟1后
把user表里剛加的那一條的hostname改成%
這樣就可以了。
如果數(shù)據(jù)庫里出現(xiàn)亂碼,則把client環(huán)境中的LANG改成GBK2312就可以了。
MYSQL ERROR 1045 (28000): Access denied for user (using password: YES)問題的解決
第一種方法: 推薦 |
|