分享java带来的快乐

我喜欢java新东西

在linux自带mysql基础上再装新的mysql

预处理:
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也可,只是以后没办法看mysql版本)
7.chown -R mysql.mysql mysql (一定要带-R)
8.执行一下./scripts/mysql_install_db --user=mysql (注意一定要在/usr/local/mysql目录下执行该命令,不能到scripts下执行mysql_install_db,目录结构有关系)
9.这时将在/usr/local/mysql/data 生成一个用户数据库(mysql)和一个test数据库 (一定要确认)
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的 
启动mysql用以下两种方式均可
(1)/etc/rc.d/init.d/mysqld start 
(2)service mysqld start
15.修改root密码
 mysqladmin -u root password 'new-password'
16.创建用户,后付所有权限

1 用于程序发布中,指定数据库,指定用户,权限小不影响工作(程序和数据库服务器在同一台机器上,否则用指定IP或域名)
grant select, insert, update, delete on notebase.* to nb@localhost identified by 'nb123';

不推荐使用%,这样所有的IP都能连接,不过只能对notebase操作
grant select, insert, update, delete on notebase.* to nb@"%" identified by 'nb123';

2 用于程序开发中,让指定开发人员的机器有最高访问权限
grant ALL PRIVILEGES on *.* to root@"10.0.0.11" Identified by "root" WITH GRANT OPTION;

flush privileges

17.进入mysql
 mysql -uroot -p770511
18.关闭数据库:
 mysqladmin -uroot -pxxxx -hxxxxxxxxx  shutdown
19(启动,关闭,连接数据库时可能出现 无法找到/usr/lib/mysql/mysql.sock错误,这是因为,机器本身自带的mysql 把socket通信文件指定在/usr/lib/mysql/mysql.sock,这时只要将本身自带的mysql和mysqladmin命令文件删除,并把/usr/local/mysql/bin置入PATH环境变量即可正常使用)



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!

 

posted on 2006-05-05 16:22 强强 阅读(850) 评论(0)  编辑  收藏 所属分类: mysql


只有注册用户登录后才能发表评论。


网站导航: