Mysql那些事兒之(一)mysql的安裝
一、Linux下安裝Mysql數據庫
首先下載Linux的Mysql安裝包
mysql-5.0.85.tar.tar
將下載好的安裝包上傳至Linux的 /usr/sid/mysql 目錄
然後繼續如下操作:
www.2cto.com
安裝步驟:
--進入Mysql的安裝目錄
cd /usr/sid/mysql
--添加一個Mysql組
groupadd mysql
--在Mysql組裡添加一個Mysql用戶
useradd -g mysql mysql
安裝:
--解壓Mysql安裝包
tar zxvf mysql-5.0.85.tar.tar
--進入mysql-5.0.85目錄
cd mysql-5.0.85
--配置Mysql的安裝路徑與相關參數
./configure --prefix=/usr/local/sunnyboysac/mysql -with-extra-charsets=gbk -with-extra-charsets=all -with-named-curses-libs=/usr/lib/libncurses.so.5 -with-innodb
--編譯
make
--安裝
make install
配置步驟:
--進入mysql解壓的目錄
cd mysql-5.0.85
--拷貝文件
cp support-files/my-large.cnf /etc/my.cnf
vi /etc/my.cnf
修改內容
添加一行
default-storage-engine=INNODB
並把innodb相關的注釋(#)去掉
改寫部分修改後的形式如下
#bdb_max_lock = 100000
default-storage-engine=INNODB
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /usr/local/eetrust/mysql/var/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/eetrust/mysql/var/
innodb_log_arch_dir = /usr/local/eetrust/mysql/var/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
<!--EndFragment-->
www.2cto.com
進入mysql目錄
cd /usr/local/eetrust/mysql/bin
添加用戶mysql
./mysql_install_db --user=mysql
--設置用戶密碼
./mysqld_safe --user=mysql &
./mysqladmin -u root password sunnyboysac
--設置mysql自啟動
--進入解壓目錄
--拷貝文件
cd /usr/sid/mysql/mysql-5.0.85
cp support-files/mysql.server /etc/rc.d/init.d/mysql
--修改權限
cd /etc/rc.d/init.d
chmod +x /etc/rc.d/init.d/mysql
--設置自啟動
chkconfig --add mysql
chkconfig mysql on
--將mysql的bin添加到/etc/profile的path中
vi /etc/profile
--在path後面加入如下內容
:/usr/local/eetrust/mysql/bin
--應用
source /etc/profile
mysql -uroot –psunnyboysac
--給mysql的用root用戶授權,使其遠程可以訪問
grant all on *.* to 'root'@'%' identified by 'mysqladmin';
grant all on *.* to 'root'@'%' identified by 'sunnyboysac';
GRANT USAGE ON *.* to root@'%' IDENTIFIED BY 'sunnyboysac';
--刷新
flush privileges;
如果還連不上,關掉防火牆
service iptables stop
www.2cto.com
驗證:
service mysql start
退出窗口重新登錄
用mysql命令
<!--EndFragment-->
<!--EndFragment-->
<!--EndFragment-->