日期:2014-05-16  浏览次数:20485 次

mysql在linux中的安装,数据库的名称大小写问题

mysql数据库在linux系统中还是区分大小写的,我以前一直以为不区分,看来我错了,以后要注意点:在linux中注意mysql数据库名称的大小写要一致。

不仅数据库的名称大小写一致,表的名称也是。

mysql在数据库中的安装步骤:

详解如下:

1)建立相应目录和组:
# mkdir /usr/local/mysql
# groupadd mysql
# useradd -g mysql mysql??????? //useradd -g mysql -d /usr/local/mysql name

2)开始安装mysql
# tar xzvf mysql-6.0.6-alpha.tar.gz?? //解压缩

# cd mysql-6.0.6-alpha //进入解压后的文件目录

# ./configure --prefix=/usr/local/mysql \???? //设定安装目录
--enable-thread-safe-client \???????????????????? //编译线程安全版的客户端库
--without-debug \????????????????????????????????????? //关闭debug功能
--with-extra-charsets=gb2312 \????????????? //添加gb2312中文字符支持
--enable-assembler \???????????????????????????? //使用一些字符函数的汇编版本
--with-raid \?????????????????????????????????????????? //激活raid支持

# make?? //编译

# make install?? //安装

3)copy配置文件
有large,medium,small三个环境下的,根据机器性能选择,如果负荷比较大,可修改里面的一些变量的内存使用值
# cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件

4)更改目录权限和组
# cd /usr/local/mysql
# chown -R mysql .
# chgrp -R mysql .

5)建立数据库和表
# bin/mysql_install_db --user=mysql?? //初始化授权

注:如果报以下错误
Installing MySQL system tables...
[ERROR] /usr/local/mysql/libexec/mysqld: unknown option '--skip-federated'
[ERROR] Aborting
[Note] /usr/local/mysql/libexec/mysqld: Shutdown complete
只要将/etc/my.cnf文件中的skip-federated注释掉即可

6)再次更改目录权限和组
# chown -R root .
# chown -R mysql var

7)启动MySQL服务
# bin/mysqld_safe --user=mysql &????????
//启动MySQL(The & character tells the operating system to run MySQL in the background;
//it is ignored by MySQL itself.
//如果报错,注意及时查看/usr/local/mysql/var/下的日志文件)

8)设置MySQL启动服务
# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld???????????? //在自动启动列表里添加mysqld
# chkconfig --level 345 mysqld on

9)修改MySQL密码
# /usr/local/mysql/bin/mysqladmin -u root password 'new-password' //修改密码
# /usr/local/mysql/bin/mysqladmin -u root -h localhost password 'new-password'
// 将localhost替换成你的主机域名,比如:zhaorg.csu.edu.cn

10)登录mysql数据库:

# mysql -u root -p
Enter password: root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18 to server version: 5.0.19-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql;
mysql>delete from user where password="";?? //删除用于本机匿名连接的空密码帐号
mysql>flush privileges;
mysql>quit

??? (或者,也可运行如下命令(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.)

11)关闭MySQL服务

# /usr/local/mysql/bin/mysqladmin -u root -p new-password shutdown?? //关闭MySQL