mysql-5.1.40-linux-i686-glibc23.tar.gz安装笔记

1.首先添加mysql用户组
Shell代码

 

Shell代码 
  1. shell> groupadd mysql  
shell> groupadd mysql

2.添加mysql用户,并指定到mysql用户组
Shell代码
  1. shell> useradd -g mysql mysql  
shell> useradd -g mysql mysql

3.解压缩mysql-version.tar.gz到安装目录(/usr/local/)
Shell代码
  1. shell> cd /usr/local  
  2. shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -  
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -

4.为创建mysql软连接mysql-VERSION-OS
Shell代码
  1. shell> ln -s full-path-to-mysql-VERSION-OS mysql  
  2. shell> cd mysql  
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql

5.设定mysql安装目录权限,设置owner为mysql
Shell代码
  1. shell> chown -R mysql .  
shell> chown -R mysql .

6.设定mysql安装目录权限,设置group为mysql
Shell代码
  1. shell> chgrp -R mysql .  
shell> chgrp -R mysql .

7.执行mysql系统数据库初始化脚本
Shell代码
  1. shell> scripts/mysql_install_db  
shell> scripts/mysql_install_db
如报错指明路径

scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 


8.回收mysql用户在安装目录下的权限,重新分配给root

Shell代码
  1. shell> chown -R root .  
shell> chown -R root .

9.设定data目录权限,分配给mysql用户,为了mysql程序能读写data目录下的文件
Shell代码
  1. shell> chown -R mysql data  
shell> chown -R mysql data

10.使用mysql帐号启动mysql应用
Shell代码
  1. shell> bin/mysqld_safe --user=mysql &  
shell> bin/mysqld_safe --user=mysql &

11.设置root密码
Shell代码
  1. shell> bin/mysqladmin -u root password '123123'  
shell> bin/mysqladmin -u root password '123123'

12.登录mysql
Shell代码
  1. shell> bin/mysql -u root -p  
  2. Enter password:  
shell> bin/mysql -u root -p
Enter password:

登录成功会看到:
Shell代码
  1. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  2. Your MySQL connection id is 229  
  3. Server version: 5.1.40-log MySQL Community Server (GPL)  
  4.   
  5. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  6.   
  7. mysql>  
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>



这时mysql已经装好了,可以查看数据库了,但在正式使用数据库开发与部署的时候还需要做一些工作:


1.设定配置文件my.cnf

    按照需求copy my-***.cnf到/etc/my.cnf

2.修改默认字符集utf8

    (1).[client]下加入default-character-set=utf8
    (2).[mysqld]下加入default-character-set=utf8

set-variable   = default_character_set=gbk

3.设置默认存储引擎
     mysql for linux的版本默认使用的数据库引擎是MyISAM,但只有InnoDB引擎支持事务,
所以需要修改配置:

    (1).[mysqld]下加入default-storage-engine=INNODB

4.配置innodb参数
  

    (1).找到# Uncomment the following if you are using InnoDB tables
        去掉innodb_*下的所有#

    (2).如果安装mysql的目录不是默认的,则需要修改
        # mysql 默认安装目录为 /usr/local/mysql/
        # mysql 默认表空间目录安装目录为 /usr/local/mysql/data/

        innodb_data_home_dir=/usr/local/database/mysql/data/
        innodb_log_group_home_dir=/usr/local/database/mysql/data/

5.设置系统服务

    让linux启动的时候就启动mysql服务

Shell代码
  1. shell> cd /usr/local/mysql/  
  2. shell> cp support-files/mysql.server /etc/init.d/mysql  
  3. shell> chmod 777 /etc/init.d/mysql   
  4. shell> chkconfig --add mysql  
  5. shell> chkconfig --level 35 mysql on  
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服务
Shell代码
  1. shell> service mysql restart  

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值